Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

joaovieira
New Contributor II

Set Analysis

Hello community, i am trying to create a KPI that returns the country of the customer that has the more sales, to get the customer i used this expression:

concat(aggr(if(rank(sum({$<Year={'$(vMaxYear)'},OrderDate={'<=$(vMaxDate)'}>}SalesFinal))<2,Customer),Customer),',')

Now the idea is to select the country of the person that the expression returns, any ideas?

Thank you for the help

1 Solution

Accepted Solutions
mark6505
Valued Contributor III

Re: Set Analysis

HI

If your above set analysis is working. i would try putting it in a Variable. vCustomer

Then trying ONLY({<Customer={'$(vCustomer)'}>}Country).

Mark

4 Replies
aronwilliamson
Contributor

Re: Set Analysis

If your expression works then you should just be able to change the "Customer" field to "Country" field as the data is linked so you will get the same result but it will return the Country

mark6505
Valued Contributor III

Re: Set Analysis

HI

If your above set analysis is working. i would try putting it in a Variable. vCustomer

Then trying ONLY({<Customer={'$(vCustomer)'}>}Country).

Mark

agigliotti
Honored Contributor II

Re: Set Analysis

maybe this:

=Only( Aggr( if( sum({$< Year = {'$(vMaxYear)'}, OrderDate = {'<=$(vMaxDate)'} >} SalesFinal) =

Max( Aggr( sum({$< Year = {'$(vMaxYear)'}, OrderDate = {'<=$(vMaxDate)'} >} SalesFinal), Country ) ), Country, null() ), Country ) )

joaovieira
New Contributor II

Re: Set Analysis

Thank you, it works well and it will help with other things i wasn't able to do.