5 Replies Latest reply: Aug 13, 2014 6:21 AM by Eric Tay

# 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:

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

Below is my sorting tab:

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

Regards,

Eric

• ###### Re: Sorting in Pivot Table

Eric,

Thanks,

AS

• ###### Re: Re: Sorting in Pivot Table

Hi Amit,

Here is the file:

Thanks,

Eric

• ###### Re: Sorting in Pivot Table

Hi,

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

Miguel

• ###### Re: Sorting in Pivot Table

Hi Miguel,

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

Eric

• ###### 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.

• ###### Re: Re: Sorting in Pivot Table

Thanks Ruben,

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

Eric