Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Eric_Tay
Employee
Employee

Sorting in Pivot Table


Dear all,

Notice that when we sort using expression in Pivot Table, sometime the sorting is incorrect.

In below example, I would like to sort the Year, Division and Category dimensions using Sum(LineSalesAmount).  When I expand the Division column, notice that the Sum(LineSalesAmount) for Year 2012 are not sorted properly, as shown below:

Image1.png

When I expand the Division and Category columns, notice that the Sum(LineSalesAmount) are not sorted properly, as shown below:

Image2.png

Below is my sorting tab:

image3.png

Any tips how to sort the Year, Division and Category dimensions using sum(LineSalesAmount) correctly?

Regards,

Eric

6 Replies
amit_saini
Master III
Master III

Eric,

Could you please share your application.

Thanks,

AS

Miguel_Angel_Baeyens

Hi,

Are you using the same expression to sort all three dimensions?

Miguel

rubenmarin

Hi Eric,

I don't have a complete answer, I can tell you this is done because QV assigns the order to the field CategoryName before he draws the pivot table, so segment dimensions (Year and Division) are not taking into account.

Sportswear is the 2nd. in Europe because the value 'Sportswear' of the field CategoryName is the 2nd with more sales on current selections (not in the year-Division in pivot table)

If you define the 3rd dimension as =Aggr(Year & '-' & Division & '-' & CategoryName, Year, Division, CategoryName) you can see then is sorted correctly, but this cause your selections in CategoryName not working as the user probably wants (not to mention the bad-looking for the CategoryName)

In script you can use Dual(CategoryName, AutoNumber(Year & '-' & Division & '-' & CategoryName)) as CategoryName but weird things also can happen with selections.

Hope this helps you to find a solution.

Eric_Tay
Employee
Employee
Author

Hi Miguel,

Yes, I am using the same expression to sort all three dimensions.

Eric

Eric_Tay
Employee
Employee
Author

Hi Amit,


Here is the file:

Thanks,

Eric

Eric_Tay
Employee
Employee
Author

Thanks Ruben,

Let me try it and I will let you know whether it works or not.

Eric