Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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
Former Employee
Former 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 )