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: 
mnbeemster
Contributor
Contributor

Read variable value by name

Is it possible to dynamically read the value of a variable:

 

load if(year(referentie_datum) = 2018,
$(v_kosten_laden_lossen_18),
$(v_kosten_laden_lossen_19)
)
as var_value

I want to get rid of the year clause. Something like:

$(v_kosten_laden_lossen_& right(year(referentie_datum,2))

Labels (1)
1 Solution

Accepted Solutions
marcus_sommer

It's just an example and you could simply extend the mapping-table to all years/values you need.

- Marcus

View solution in original post

3 Replies
marcus_sommer

I think I wouldn't use multiple variables for such a case else just a mapping like:

map: mapping load * inline [
Jahr, Wert
2018, 1
2019, 2];

and then:

load *, applymap('map', year(referentie_datum), 'any default value') as var_value
...

- Marcus

mnbeemster
Contributor
Contributor
Author

Hi Marcus,

 

thanks for helping, but I have more than one 1 variable:

 

Var1  ---- value 2018 ---- value 2019
Var2  ---- value 2018 ---- value 2019
etc

Next year, there will be value 2020

marcus_sommer

It's just an example and you could simply extend the mapping-table to all years/values you need.

- Marcus