Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

m_perreault
Contributor II

Using a Variable in a Field Name in an Expression

Hello,

The data I am working with has fields broken down as '2018 Sales' and '2017 Sales'.  I would like to create a variable for current year and use it in my field name within an expression.  For example if my variable vCurrentYear =  max(Year) I would like to be able to use an expression along the lines of  sum("$(vCurrentYear) & Sales") to give me the sum(2018 Sales).  Does anyone know if this possible and how to do it?

Thanks!

1 Solution

Accepted Solutions
juraj_misina
Valued Contributor

Re: Using a Variable in a Field Name in an Expression

Or, if you have a variable as you mention, simply Sum([$(vCurrentYear) Sales])

3 Replies
Digvijay_Singh
Honored Contributor III

Re: Using a Variable in a Field Name in an Expression

May be something like this -

=Sum($(='['&Max(Year)&' Sales'&']'))

juraj_misina
Valued Contributor

Re: Using a Variable in a Field Name in an Expression

Or, if you have a variable as you mention, simply Sum([$(vCurrentYear) Sales])

m_perreault
Contributor II

Re: Using a Variable in a Field Name in an Expression

This works perfectly thank you