Skip to main content
Announcements
Qlik Introduces a New Era of Visualization! READ ALL ABOUT IT
cancel
Showing results for 
Search instead for 
Did you mean: 
qlikuser22
Creator II
Creator II

How to use the variable to switch between two dimensions?

Hi,

I have to switch between Local Currency, EUR and USD. I have created the dimension as Cost_LC, Cost_USD, Cost_EUR. 

I  need to create a variable for currency and use that in KPI's and graphs. 

I also have a button for the currencies. I need to switch between the 3 KPIs.

How to create a variable? and how to use it in KPIs. 

Please need some as I am new to qlik. 

 

Thanks. 

 

 

Labels (5)
1 Solution

Accepted Solutions
Or
MVP
MVP

You would create the variable as containing whichever currency you want to be the default, and use the Variable Input object to allow the user to change it.

View solution in original post

9 Replies
Or
MVP
MVP

You can create a variable either from the script (using a Set or Let statement) or from the Variable Editor in the bottom left corner of Edit Mode. Controlling the variable inputs using the Variable Input object is pretty self-explanatory and covered in the documentation if necessary.

Your eventual formulas would be something like Sum(Pick(Match(vCurrency,'LC','USD','EUR'),Cost_LC, Cost_USD,Cost_EUR)) or if preferred, you could write this out with a pair of if() statements instead.

qlikuser22
Creator II
Creator II
Author

Hi @Or ,


Thanks a lot for the quick reply. . 

Can I get some help in writing the variable in the variable editor and use that in expression. 

For example: I have this expression, I need to modify it using the variable.


SUM({$<YearMonthDay={$(vL.MaxYearMonthDay)}, Status={'no'}>} Aggr(Sum(DISTINCT Cost_EUR), [%ID]))

I need to use the variable in this expression and something similar in the graphs where I should switch between the other currencies. 

How do I modify it?

Thanks! 

Or
MVP
MVP

You would use the exact formula from my previous post (assuming your variable was named vCurrency).

qlikuser22
Creator II
Creator II
Author

Could You please elaborate. I am stuck. 

 

Should I create a variable as,

vCurrency = 'EUR','USD','LC' ?

Or
MVP
MVP

You would create the variable as containing whichever currency you want to be the default, and use the Variable Input object to allow the user to change it.

qlikuser22
Creator II
Creator II
Author

Hi,

I modified like this,

SUM({$<YearMonthDay={$(vL.MaxYearMonthDay)}, Status={'no'}>} Aggr(Sum(DISTINCT Cost_$(vCurrency)), [%ID]))

 

and vCurrency = 'EUR','USD','LC';

 

But no luck. Am I right?

Or
MVP
MVP

No. If you want to write it that way you would need something like $(='Cost_' & vCurrency). I personally do not like using that method unless the list of possible variable values is too long for Pick/Match to be feasible, so I would personally not use that approach.

vCurrency should always have a single currency selected. It should not have three comma-separated "options".

qlikuser22
Creator II
Creator II
Author

What should be defined in vCurrency ? 

qlikuser22
Creator II
Creator II
Author

Super. It worked 🙂 Thanks for guiding!