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
3 Keynotes, 100+ Breakout Sessions, 1 New York Times bestseller, and you. QlikWorld Online, May 10-12: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
sofiavaz
Creator II
Creator II

Sort a calculated dimension by Expression

Hi all,

I have two tables, each one with a calculated dimension and a measures.

One of the dimensions is called "Markets" and will divide my measure by EUR, USA, INT and Others. How can I define the order like that? What expression should I use? I've tried a lot of things but not've been succeded.

Thank you.

Sofia Vaz

7 Replies
OmarBenSalem
Partner
Partner

Have u tried to use the sort tab and put ur measure above?

mohan_1105
Partner
Partner

Can you explain it clearly?

Do you want to sort the dimension in a way EUR, USA, INT and Others?

sofiavaz
Creator II
Creator II
Author

Yes. I've tried expressions like this one

if([Markets] ='Europe',1 

,if([Markets] ='USA',2 

,if([Markets] ='International ',3 

,if([Markets] ='Others',4 )))) 

in the sort tab but it doesn't recognize [Markets] as a dimension .

If I put the measure above I'll be sure that the dimension fields will be always as they appear now (by chance, in this case, if I do that it will sort the dimensions as I want, but in other cases it doesn't)

sofiavaz
Creator II
Creator II
Author

Yes, that's it.

mohan_1105
Partner
Partner

Use this,

if([Markets] ='Europe',Dual('Europe',1)

,if([Markets] ='USA',Dual('USA',2)

,if([Markets] ='International ',Dual('International',3)

,if([Markets] ='Others',Dual('Others',4)))))

And sort it numerically..!!

suepenick
Creator
Creator

In the load script

FoodSortOrder:

Load * Inline

[Food, FoodSortOrder

Eggs,1

Bacon,2

Bread,3

Potatoes,5

Milk,6

Coffee,7];

then in the Chart, Sort Tab, click the Dimension you want the sort to happen - in this case Food

check the sort by expression

and key FoodSortOrder in the expression field.

it will sort in the numeric order that you defined

sofiavaz
Creator II
Creator II
Author

Thank you Sue. Unfortunately I'm not allowed to edit the scrip. I've solved the problem with Mohan expression.

thanks!

Sofia Vaz