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: 
Not applicable

Sorting within pivot tables

I have created a pivot table with the dimensions payer, product and month, where months are in columns. The expression is the total sales column. I want the payers to be sorted based on latest month's highest sales volume and within payers the products should be sorted based on the descending order of the sales for each product in latest month. I have used expression to sort the data  sum (if(monthdate=max(monthdate), sales). Could you please advise on how I should set up the sorting?

8 Replies
ramoncova06
Partner - Specialist III
Partner - Specialist III

under the sort section your first field has to be the month, then payer and then product

you can change your expression to the following sum({< monthdate = {"$(=(max(monthdate))"}>}sales) (this is also faster than using if's)

Not applicable
Author

Thank you Ramon!

I used this expression and it is sorting the first dimension i.e. payer but is it not sorting products within each payer. I also want the products within each payer sorted in descending order.

ramoncova06
Partner - Specialist III
Partner - Specialist III

did you add the expression to the products ?

Not applicable
Author

Yes, I tried that. I have also tried aggr(sum({< monthdate = {"$(=(max(monthdate))"}>}sales),payer). It is also not working.

ramoncova06
Partner - Specialist III
Partner - Specialist III

Not in front of a computer right not but try by using a rank(expression)

Anonymous
Not applicable
Author

Not possible.  You cannot have 2nd (3rd, etc.) dimension to be sorted differently in each group.

vikasmahajan

You can create Straight table instead of pivot , This are faster in performance also.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
sunilkumarqv
Specialist II
Specialist II

Hi swatsaraora,


Take your measure expression and then put that expression in sort it in descending order

and exclude  other options

example

sum({<Year={"$(=Max(Year))"},Month=,Qtr=,Date=,Products=>}Amount )