# App Development

Announcements
QlikWorld happening right now! You can still join: REGISTER NOW
cancel
Showing results for
Did you mean:
Creator II

## Sorting within a dimension in a pivot table.

Hi,

I am trying to use a sorting function but due to the logic its unable to perform.

I will explain through a example.

Suppose I have two dimensions : Product Family and Customer.

Each product family have different customers. Customers in different product families could be the same.

Eg: Product Family : ABC,  XYZ

Customer : Ford , Nissan

Measure : Sum (Revenue)

I create a pivot table which has Primary Sorting for Product Family by Revenue(descending order). The seconday sorting is for Customer again by Revenue(descending order).

Product Family    Customer     Revenue

ABC                      Ford            \$ 100

Nissan        \$ 200

XYZ                      Ford            \$200

Nissan         \$10

Total of ABC =\$ 300, XYZ = \$210.

So the sorting is Ok.

But what i want is that Ford and Nissan should also rearrange themselves in descending order in their product families.

According to the logic, it sums up the revenue for Ford =\$300, Nissan=\$210 and that is why Ford always appears above Nissan in product families.

How could we accomplish this task ??

So that in ABC the order is Nissan, then Ford. Xyz has the order Ford then Nissan.

Labels (1)
• ### expression

1 Solution

Accepted Solutions
Partner

As gwassenaar‌ explains in Is it possible to sort measure in pivot table using Qlik Sense?, you need to replace the dimension you want to sort by with a dual function. So... your first dimension will be ProductFamily but the second will be " Dual(Customer, Aggr(Sum(Revenue),ProductFamily,Customer)) ". Then you can sort the second dimension numerically in the sort tab.

Review the enclosed file to see the example.

10 Replies
Partner

As gwassenaar‌ explains in Is it possible to sort measure in pivot table using Qlik Sense?, you need to replace the dimension you want to sort by with a dual function. So... your first dimension will be ProductFamily but the second will be " Dual(Customer, Aggr(Sum(Revenue),ProductFamily,Customer)) ". Then you can sort the second dimension numerically in the sort tab.

Review the enclosed file to see the example.

Partner

In Sorting Tab,

Go to Customer - Choose sort by Expression, use Revenue Expression there and apply descending order.

It works.

Specialist

Hi

PFA the attached .qvw for your reference.

Regards

Pratyush

Creator II
Author

Thanks a ton.

It works, but when i try to select something in the filter, the filter shows no value.

It should show me Ford GM etc.

Do you have any suggestions?

Creator II
Author

Thanks Pratyush for the reply. Can you send me a qvf file.

This file doesnot runs on my Qlik Sense

Creator II
Author

Hi Sharddha,

I tried that and simply sorting it out was not solving the problem.

Creator II
Author

Also, when i just try Customer in the expression.

The filter works.

It only doesnot works with the dual expression.

Creator II
Author

So, i got a way to run the QVW file in QVF,

But i could not see any sheet or any visualization.

Can you please send me the expression you used?

Creator II

It works unless you rearrange dimensions in pivot table (e.g. "Customer" before "Product Family")