Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
KerstinP
Contributor
Contributor

Sort by with an if clause

Hello,

I have a dimension (Product) and a value (Orders). I created a variable to switch between the value of the orders itself and the amount of the orders. 

=if((vDefaultAmount)='Value',
Sum(Orders)/1000,
Sum(Amount_Orders))

How can I sort the data. I always want to see the sorting by the value of the orders - even my variable is shwoing Amount.

And how can I change the format. My values should look like 0'000 and my amount like 0.000?

Thanks for your help! 

BR Kerstin

Labels (1)
2 Replies
brunobertels
Master
Master

Hi 

may be to format number 

replace(num(Sum(Orders),'#,###'),',',chr(39))

 

=if((vDefaultAmount)='Value',
num(Sum(Orders),'#,###') ,
replace(num(Sum(Amount_Orders),'#,###'),',',chr(39))

)

 

for sorting order 

Use the rank function 

rank(Sum(Orders)) 

 

KerstinP
Contributor
Contributor
Author

Hi

thanks, for your response!

Qlik no longer displays quantity. I don't know why. 

And the sorting does not work. It is still the old wrong order. Is it correct to put it into the tab "sorting"?

BR, Kerstin