Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
vvvvvvizard
Partner - Specialist
Partner - Specialist

Max client name based on expression

LOAD * Inline [

Client , Tickets

A , 20

b , 20

C , 30

A , 20

D , 5

];

This return the highest number of tickets a client has

=Max(aggr(Sum(Tickets),Client))

Now how do I return the client name with the highest number of tickets in a textbox

1 Solution

Accepted Solutions
sunny_talwar

Or this

Only({<Client = {"=Rank(Sum(Tickets)) = 1"}>}Client)

View solution in original post

15 Replies
YoussefBelloum
Champion
Champion

Hi,

you can try this on a textbox:

=FirstSortedValue(Client,-Tickets)

vvvvvvizard
Partner - Specialist
Partner - Specialist
Author

I edited the inline table  it so both A add up to 40 , instead your expression returns C , instead of A

YoussefBelloum
Champion
Champion

because the values are not grouped in the back end, you need to group your measure by the Client dimension using Aggr()

like this:

=FirstSortedValue(Client,-aggr(sum(Tickets),Client))

sunny_talwar

Or this

Only({<Client = {"=Rank(Sum(Tickets)) = 1"}>}Client)

YoussefBelloum
Champion
Champion

Hi Sunny,

I was thinking about this and try to use it, but didn't work, I think it need some grouping inside the Rank function..

sunny_talwar

Grouping inside rank? Don't we already have Sum() to group?

YoussefBelloum
Champion
Champion

Yes, because here the Rank 1 you will find on A and C, so the expression will take which Client Value ?

YoussefBelloum
Champion
Champion

I tried this and it worked:

=Only({<Client = {"=Rank(aggr(Sum(Tickets),Client,Tickets)) = 1"}>}Client)

sunny_talwar

But this didn't work?

Only({<Client = {"=Rank(Sum(Tickets)) = 1"}>}Client)

That is so strange... let me give it a shot