Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable as field name

Hi,

I have the following steps to calculate the total value depending on a currency selection button:

1) A button to select  between Local Currency/ Euro. The selection is kept in a variable vCurrency (Values can be LC or EUR)

2) A variable: vCurrencyField to select either the field of LC [Amount LC] or the field with EUR calculations [Amount EUR]. The formula I am using is: =if((vCurrency)='EUR','[Amount EUR]','[Amount LC]')

3) I want to use vCurrencyField in another variable vAmount : sum({<Year={$(vCurrent_Year)},Type={$(vType)}>}$(vCurrencyField))

Unfortunately this does not work. Am I missing any $ or = signs? or what could be the problem?

Best regards,

AD

2 Replies
m_woolf
Master II
Master II

2) Field names don't include the square brackets.

JonnyPoole
Employee
Employee

i think #2 is wrong too... lose the single quotes


=if((vCurrency)='EUR',[Amount EUR],[Amount LC])


OR #2 is right and you can lose the $() on the vCurrencyField in #3


sum({<Year={$(vCurrent_Year)},Type={$(vType)}>}  vCurrencyField )