Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikwiz123
Creator III
Creator III

Aggregate Rank() on a field

 

Please look at the screenshot below.

Capture.JPG

 

I just sorted on Funds from Highest to lowest and since CVS HEALTH has the highest Funds overall, the Rank for all CVS from 'Giver' column should be 1.

Then all rows with 'Giver' -  ANHEUSER-BUSCH CO/INBEV should be 2, COMCAST A should be 3 and so on...

Labels (3)
1 Solution

Accepted Solutions
Nicole-Smith

So it sounds like you want max() instead of sum()?

Using the following as a dimension:
=Aggr(Rank(aggr(max(Funds),Cat), 1, 1),Cat) 

Results in this:

Cat Company Date Giver Funds max(total <Cat> Funds) =Aggr(Rank(aggr(max(Funds),Cat), 1, 1),Cat) 
CVSA3/6/2018CVS HEALTH A900000000090000000001
CVSA3/6/2018CVS HEALTH A800000000090000000001
CVSA3/6/2018CVS HEALTH A600000000090000000001
CVSA3/6/2018CVS HEALTH A500000000090000000001
CVSA3/6/2018CVS HEALTH A300000000090000000001
CVSA3/6/2018CVS HEALTH A200000000090000000001
CVSA3/6/2018CVS HEALTH A100000000090000000001
ABIBBA3/20/2018ANHEUSER-BUSCH INBEV WOR250000000042500000002
ABIBBA3/20/2018ANHEUSER-BUSCH INBEV WOR150000000042500000002
ABIBBA3/20/2018ANHEUSER-BUSCH INBEV WOR50000000042500000002
ABIBBA1/10/2019ANHEUSER-BUSCH CO/INBEV425000000042500000002
ABIBBA1/10/2019ANHEUSER-BUSCH CO/INBEV400000000042500000002
ABIBBA1/10/2019ANHEUSER-BUSCH CO/INBEV250000000042500000002
ABIBBA1/10/2019ANHEUSER-BUSCH CO/INBEV200000000042500000002
ABIBBA1/10/2019ANHEUSER-BUSCH CO/INBEV75000000042500000002
CMCSAA2/1/2018COMCAST A120000000040000000003
CMCSAA2/1/2018COMCAST A100000000040000000003
CMCSAA10/2/2018COMCAST A400000000040000000003
CMCSAA10/2/2018COMCAST A300000000040000000003
CMCSAA10/2/2018COMCAST A250000000040000000003
CMCSAA10/2/2018COMCAST A200000000040000000003
CMCSAA10/2/2018COMCAST A175000000040000000003
CMCSAA10/2/2018COMCAST A150000000040000000003
CMCSAA10/2/2018COMCAST A125000000040000000003
CMCSAA10/2/2018COMCAST A100000000040000000003
CMCSAA10/2/2018COMCAST A50000000040000000003
CIA9/6/2018CIGNA A380000000038000000004
CIA9/6/2018CIGNA A310000000038000000004
CIA9/6/2018CIGNA A300000000038000000004
CIA9/6/2018CIGNA A220000000038000000004
CIA9/6/2018CIGNA A175000000038000000004
CIA9/6/2018CIGNA A125000000038000000004
CIA9/6/2018CIGNA A100000000038000000004
CIA9/6/2018CIGNA A70000000038000000004

 

Also attaching the example file with this change.

View solution in original post

13 Replies
Nicole-Smith

The following works as a dimension:

Untitled.png

qlikwiz123
Creator III
Creator III
Author

@Nicole-Smith 

Hi,

Please find the Attached QVW. The same is not working on my end.

Nicole-Smith

It's working properly based on the sum of Funds per Cat (I've updated the chart in your example file to contain the sum of Funds by Cat as an expression).

Do you maybe want it grouped by Giver instead of Cat?  I've added a second chart that does that.

qlikwiz123
Creator III
Creator III
Author

@Nicole-Smith  Thanks you so much. Let me check this one

qlikwiz123
Creator III
Creator III
Author

 
qlikwiz123
Creator III
Creator III
Author

@Nicole-Smith 

Please look at the attached Excel Source file. Here, you can clearly see that the Highest to lowest Funds with respect to Cat, the order is different. I have added a Rank column manually to help you understand how my rankings should look like.

1. How do I get them to show same rank if the Funds value is same instead of multiple numbers like below?

Capture.JPG

2. This is how my Ranks should look like, if you look at the Excel file sorted based on Funds from highest to lowest.

Capture.JPG

Nicole-Smith

If grouping by Cat, JPM totals to more than CVS (as seen in the first chart in my previous example file--second to last column).  I'm not sure what your Excel file is doing to ignore JPM.  From the totals on that first chart, I can see that the ranking function that I wrote is working properly.

If you want it to show the values without the dashes, you can change the extra parameters of the Rank function to fit your needs.  I usually go with 1 and 1 but other options can be found here.  For example:
=Aggr(Rank(aggr(Sum(Funds),Cat), 1, 1),Cat)

qlikwiz123
Creator III
Creator III
Author

If you look at the Excel file attached or even the screenshot, JPM is not the highest Funds, it is the CVS and then ABIBB and CMCSA and so on....

Nicole-Smith

You're right--the sum I have isn't working properly.  If I can figure out why, I can fix this rank function...