Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need to Reuse expression definition

Hello Folks,

I am developing multi-tab report in Qlikview 11. I want to create a generic code which I can use at multiple places like below.

I have input box in which I am setting currency_var (GBP,USD etc)

I created variable as

Variable : Currency_Rate

=if( currency_var = 'USD', 50, if ( currency_var = 'GBP' , 79,0))

and used that variable in expression of my pivot chart. as below

Expression : Amount

= sum( Revenue * Currency_Rate)

But it shows 0 when I put the variable. But if I replace my definition in expression to

=sum( Revenue * if(currecy_var = 'USD',50,if( currency_var = 'GBP', 79,0)) )

then it works. I want to reuse the "Currency_rate" definition at many places so that whenever factor is changed I can just change variable and get effect across all such expressions implemented in document.

any ideas ?

Thanks in advance

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

First, create the variable without a leading = sign (so that you save the expression rather than the result)

Second, your expression should read

     =Sum(Revenue * $(Currency_Rate))

     or (if that does not work

     =Sum(Revenue * $(=$(Currency_Rate)))

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

First, create the variable without a leading = sign (so that you save the expression rather than the result)

Second, your expression should read

     =Sum(Revenue * $(Currency_Rate))

     or (if that does not work

     =Sum(Revenue * $(=$(Currency_Rate)))

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
giakoum
Partner - Master II
Partner - Master II

try this :

= sum( Revenue * $(Currency_Rate))

Not applicable
Author

Thanks Jonathan, Ioannis.. It worked !!!