Qlik Community

Ask a Question

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Become an analytics expert with Qlik's new 15 week course: Applied Data Analytics using Qlik Sense. READ MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
PrashantRupani
Creator
Creator

Sort Ascending or Descending in a chart

Hi,

I have a chart which changes the dimension based on a filter dropdown ( By Region, Product, Manager).

When the dimension is Region then sort Ascending by Region.

When other dimensions, then sort  Descending by Sales. 

How do I achieve this in Sort expression ?

Thanks for your support.

 

Labels (1)
3 Replies
jwjackso
Specialist II
Specialist II

Using this data:

Data:
Load * Inline [
Region,Product,Manager,Sales
R1,P1,M1,100
R2,P2,M2,200
R3,P3,M3,300
R4,P4,M4,400
];

Filter:
Load * Inline [
Filter
Region
Product
Manager
];

 

Disable the sort on all dimensions except for region which is sorted descending.  I used this expression:  =If(GetFieldSelections(Filter) = 'Region',Match(Region,R4,R3,R2,R1),Sales)

The Match function is reordering the Region.

cap1.pngcap2.png

PrashantRupani
Creator
Creator
Author

 

I have only one dimension  column which is changing based on the selection of dimension in the filter( Region , Manager, Product).

If I select Region, then only Region and Sales will be displayed. Sort by Region ASC

If Manager then Manager and Sales. Sort by Sales DESC

If Region then Region and Sales. Sort by Sales DESC

I tried the solution you gave but it did not work.

 

Thanks

jwjackso
Specialist II
Specialist II

Using this data:

Data:
Load * Inline [
Region,Product,Manager,Sales
R1,P1,M1,100
R2,P2,M2,400
R3,P3,M3,300
R4,P4,M4,200
];

Filter:
Load * Inline [
Filter
Region
Product
Manager
];

cap1.pngcap2.pngcap3.png

The table dimension is defined as:

=If (GetFieldSelections(Filter) = 'Region',[Region],
If(GetFieldSelections(Filter) = 'Manager',[Manager],[Product]))

 

The sort expression, set to descending:

=If(GetFieldSelections(Filter) = 'Region',Match(Region,'M4','M3','M2','M1'),Sales)