Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Is it possible to use a variable as a part of a field name

Hi. I´m trying to change the name of a field which is in to an expression using a variable as a part of the field name.

For example something like this:

    Having 2 measures:   Quantity, and Sales

     And a group of fields that contains the measure in the field name: Qty_month , S_month

Is possible to do something like this:

    Create a variable:  V_measure which will have 2 possible values 'Qty' or 'S' an use it in a expression as follows:

                                                               SUM(V_measure&'_month')  

Thank you

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Yes, that's indeed possible and quite useful in cases like yours, or multilanguage scenarios. This will work in a multibox, and will work as well in any expression:

="$(='Year ' & vTypeOfDate)"

Where Year is the fixed part and vTypeOfDate a variable with some fixed values the user can select. Depending on that selection, the field and values shown will differ according to the complete result of that expression.

Hope that helps.

Miguel

View solution in original post

5 Replies
jjfabian
Partner
Partner

Hi there,

I don't know about your specific problem, but I would build 2 expressions and enable them conditionally instead. That should work for sure.

Not applicable
Author

Hi Jakob.

Now I´ve a huge expression with nested IF, and I´m trying to simplify the expression.

I´m asking because I´ve more than 2 measures, that was only an example.

Thanks for answering

Miguel_Angel_Baeyens

Hi,

Yes, that's indeed possible and quite useful in cases like yours, or multilanguage scenarios. This will work in a multibox, and will work as well in any expression:

="$(='Year ' & vTypeOfDate)"

Where Year is the fixed part and vTypeOfDate a variable with some fixed values the user can select. Depending on that selection, the field and values shown will differ according to the complete result of that expression.

Hope that helps.

Miguel

View solution in original post

Not applicable
Author

Hi Miguel

Your answer have put me in the way. With your help this is the expression i've built:

=sum($(=V_measure&'_Month'))   And it Works !!!!   

Thank you !!!

stuurstuur
Contributor
Contributor

Hi Miguel,

Thanks for your reply and I'm happy it works (for others :p). I'm doing the same trick, now in Qlik Sense. I also have different viewpoints on the same data: Sales, Production..

First part of the Fieldname is #Sales, #Production.. Second part is Qty, QtyKG, AmountEUR  (example together: #SalesQty)

This is the variable (vMeasureFieldTEST) I made (using an object in the front end witch gives 1, 2, or 3): 

If(vMeasure=1, 'QtyKG',
If(vMeasure=2, 'AmountEUR',
If(vMeasure=3, 'Qty')))

The string: sum("$(='#Sales' & vMeasureFieldTEST)").

It gives 0. What goes wrong? How to make it work?

Kind regards, Arnoud