Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

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
Honored Contributor III

Re: Sorting in Pivot Table

Eric,

Could you please share your application.

Thanks,

AS

MVP
MVP

Re: Sorting in Pivot Table

Hi,

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

Miguel

Re: Sorting in Pivot Table

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.

Employee
Employee

Re: Sorting in Pivot Table

Hi Miguel,

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

Eric

Employee
Employee

Re: Re: Sorting in Pivot Table

Hi Amit,


Here is the file:

Thanks,

Eric

Employee
Employee

Re: Re: Sorting in Pivot Table

Thanks Ruben,

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

Eric

Community Browser