Skip to main content
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 III
Specialist III

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 III
Specialist III

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)