Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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.
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
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
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 !!!
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