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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to sort top 5 within Pivot table

GroupVendorID Counts
A146
A213
A3200
A412
A52

I have a pivot table where I am counting IDs (3rd column above) for top 5 vendors grouping by Group. Within Groups, only A is shown here, I want the ID Counts to sort in descending order. So in the table above it sud be in 200,46,13,12,2 order.

I am using the following expn to count IDs: sum(aggr(if((rank(count({ fieldA = {1}>} ID))) <=5,count({<FieldA = {1}>} ID)),Group, Vendor))

How do I make it to sort within the group with max count at the top?

12 Replies
Anonymous
Not applicable
Author

Thank you sunindia‌  and swuehl‌ for helping out. I will implement these in my app and update.

Anonymous
Not applicable
Author

Swuehl,

It works almost perfectly. But my actual app has one more condition; the order of the Group is not "Normal".

from the image below: The user wants the sort order to be B -101, A -102, D -103, C -104. How to make this possible.

I thought we had this under control. Thanks for your help again.

rank_sort_2.PNG

swuehl
MVP
MVP

Maybe use a $Sort expression like

Pick(Dimensionality(),

Subfield([$(=GetObjectField(0))],'-',2),

-Column(2)

)