Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Firstsortedvalue error

Hi all,

I have requirement to get the TOP 3 products.  The data i got is as below:

Department    Category     Product      Runs  Type   Percent

Department B  Category 1  Product A  5           1      20%

Department B   Category 1  Product B  6           1    16.67%

Department B    Category 1 Product A  4            2    50%

Department B     Category 1 Product B  5         1      20%

Expected results is:

Department      Category      Runs    Type    Percent   TOP1 Product   Runs   Type  Percent     TOP2   Product Runs    Type   Percent

Department B    Category 1   20        5         25%         Product A          9          3       33.33%      Product B          11         2        18.18%

For getting the TOP1 Product i have written the code:

=FirstSortedValue(distinct Product, Num(Aggr(Rank( total sum(type) + sum(Percent),4),Department,Category)),1)

For getting the TOP1 Product Runs i have written the code:

=FirstSortedValue(distinct Run, Num(Aggr(Rank( total sum(type) + sum(Percent),4),Department,Category)),1)

I want to sum the Run for each product.

Please help me.

1 Solution

Accepted Solutions
sunny_talwar

Try this

=FirstSortedValue(Aggr(Sum(Run), Department, Category), Num(Aggr(Rank(TOTAL Sum(type) + Sum(Percent), 4), Department, Category)), 1)

View solution in original post

2 Replies
sunny_talwar

Try this

=FirstSortedValue(Aggr(Sum(Run), Department, Category), Num(Aggr(Rank(TOTAL Sum(type) + Sum(Percent), 4), Department, Category)), 1)

Anonymous
Not applicable
Author

Thank you!  It works.