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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Thathayoyo
Contributor III
Contributor III

Pivot Table: Sort ascending/descending by expression and apply sorting to all dimensions

Hello,

I have a pivot table where i am trying to sort my columns (dimensions) either ascending or descending order dynamically. For this i have two buttons that return a boolean (vSort) : -1 if you click on descending or 1 if you click on ascending.  In my pivot table , in "Sorting" then I  "Sort by expression:" =if($(vSort) = 1, Count([Number]),-Count([Number]))  where Count([Number]) is my Measure in the pivot table.

 

The problem is that the sorting only applies to the first dimension of the table and I am trying to apply it to all dimensions. Do you have an idea how to do it?

 

Thanks.

Labels (6)
2 Replies
Sayed_Mannan
Creator II
Creator II

To apply dynamic sorting to all dimensions in pivot table, you can use a combination of the Aggr function and sorting expressions for each dimensions.

let's say you have 3 dimensions, dim1, dim2 and dim3.

based on your sorting expression you can do this:-

for Dimension1: 

>go to the soring setting for Dim1

>Select "Sort by Expression"

>Enter the sorting expression: =Aggr(If($(vSort) = 1, Count([Number]), -Count([Number])), Dim1)

 

for Dimension2: 

>go to the soring setting for Dim2

>Select "Sort by Expression"

>Enter the sorting expression: =Aggr(If($(vSort) = 1, Count([Number]), -Count([Number])), Dim2)

and so on.

I hope this will help you.

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @Thathayoyo 

Dont know if the dimensionality might work for this. Perhaps give it a try.

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn