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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
aaronnayan
Creator III
Creator III

Set Analysis Question

Hi Guys,

Really quick

i have a KPI :

max(aggr($(vMargin),[CustomerName]))

Which gives the value £

I want to get the Name 'String'of the customer with the most Margin?

Thanks

1 Solution

Accepted Solutions
OmarBenSalem

per analogy :

='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))

result :

Capture.PNG

View solution in original post

11 Replies
OmarBenSalem

maybe:

=firstsortedvalue ([CustomerName], -aggr( max($(vMargin)),[CustomerName]))

or

=firstsortedvalue ([CustomerName], -max(aggr($(vMargin),[CustomerName])))

OmarBenSalem

per analogy :

='Customer with the most Sales : '&firstsortedvalue (customer, -aggr( sum(sales),customer))

result :

Capture.PNG

aaronnayan
Creator III
Creator III
Author

Hi Omar its coming back with a null value

aaronnayan
Creator III
Creator III
Author

Both are not working. Maybe becuase of the variable?

OmarBenSalem

what's in the variable?

aaronnayan
Creator III
Creator III
Author

I have changed the name of the fields for security

sum({<SInvoiceCount = {1}>} [Marginlcc]) + sum({<SCreditC = {1}>} [Marginlcc])

andrei_delta
Partner - Creator III
Partner - Creator III

hi,

you have a mistake in the formula:


sum({<SInvoiceCount = {1}>} [Marginlcc]]) + sum({<SCreditC = {1}>} [Marginlcc])


hope it helps,

Andrew

aaronnayan
Creator III
Creator III
Author

No andrew thanks for spotting that i changed it due to security

The variable works fine on its own

OmarBenSalem

What if u put the expression in ur variable directly in mine?

It works?