Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Josimpkins
Contributor
Contributor

Using multi-conditional IF statement with variable to format values

Hi All,

 

I am new to Qlik, but I have scoured the interweb on this one and cannot find an answer.  I have an app where I want to format the values as either money or a number based on the selection of the user.  I am using various variables and also have a variable input item used to switch between Sales and Items (hence the need to switch formats).  The issue I am running into is that I want to use the selection of the user in that variable input to decide what format to start with, then use the value to determine whether I display converted to 'K' or 'M'.

I have put my calculation below, but what happens when I uncomment the part of the If statement that uses the metric value is that I get an 'OK' from the script validation tool, but a return of 0 results.  It does not seem to want to use my variable without some sort of aggregation.  

Any help here would be much appreciated!

 

if(

// $(=vMetricType)=Sales and

sum({<InvoiceDate = {">=$(vCurrentYear_FirstDate) <=$(vCurrentDate_MaxDate)"}>}$(vMetricType))>=1000000,


NUM(sum({<InvoiceDate = {">=$(vCurrentYear_FirstDate) <=$(vCurrentDate_MaxDate)"}>}$(vMetricType))/1000000,'$#,##0.##M;-$#,##0.##M'),


NUM(sum({<InvoiceDate = {">=$(vCurrentYear_FirstDate) <=$(vCurrentDate_MaxDate)"}>}$(vMetricType))/1000,'$#,##0.##K;-$#,##0.##K'))

 

Labels (2)
1 Solution

Accepted Solutions
rubenmarin

Hi, maybe it's because you need to add simple quotes: '$(=vMetricType)'='Sales'

View solution in original post

2 Replies
rubenmarin

Hi, maybe it's because you need to add simple quotes: '$(=vMetricType)'='Sales'

Josimpkins
Contributor
Contributor
Author

That did it!  Thank you!