Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I am having some issues when using the IF condition in "Label" box in Qlik Sense.
When I use the same condition in the "Expression" box it works.
The statement is the following:
= If([Master Measure %] < 0.25, 'Class A',
If([Master Measure %] < 0.35, 'Class B',
If([Master Measure %] < 0.45, 'Class C',
If([Master Measure %] < 0.55, 'Class D', 'Class E'
))))
As output I always get 'Class E' even when the [Master Measure %] is below 0.55. If I copy paste the same above statement in the "Expression" box it returns the correct answer (i.e. 'Class C' when [Master Measure %] is below 0.55), so I believe that the problem is related to the "Label" box. Maybe because Qlik can't read the numeric condition properly.
Does anyone know how to solve this?
Thank you very much,
Tommaso
What is [Master Measure %]? A column from one of your tables, or a master expression within your app? Does it always have exactly one value when evaluated in the global context (e.g. in a text box or header)?
In that case, what happens if you just place =[Master measure %] in your label, without the surrounding If()? Does it evaluate to the expected value?
Hi @Or,
when I put =[Master measure %] in the "Label" box without the If() condition it doesn't give the expected value. It just shows '-'
Maybe the way [Master measure %] is defined cannot be evaulated correctly within the If() condition. I still don't know how to solve this.
If you are not getting a result for =[Master measure %] when used in your label box, that means it's not evaluating to a value in this context. I assume you would get the same behavior if you place it in e.g. a text box. That also explains why your if() statement won't work - the formula returns null, so you're always triggering the last Else condition in the statement.
Without knowing what the formula inside is and without knowing what the data looks like, I can't help any further - I'd suggest you pull the formula from this measure, place it directly into the label, and see if that works to return the expected value. If it doesn't, you'll need to troubleshoot the formula until it does. If using the formula directly rather than a reference to the master measure does work correctly, I'd suggest you just use that approach.
Thank you for your answer @Or
[Master measure %] is a measure that evaluates the cumulative lost quantity up to a certain month with respect to the incoming quantity, it is defined as
Aggr(RangeSum(Above(Quantity_LOST,0,RowNo())),Month)
/
Aggr(RangeSum(Above(Quantity_IN,0,RowNo())),Month)
When [Master measure %] is used in charts, it works fine and returns a percentage of lost quantity, as shown here below
So I was trying to create a Tooltip that shows the Class name at a certain month. For example, if I put my cursor on March I need to see "Class C".
Probably you are right, the way [Master measure %] is defined cannot be evaluated correctly in the Tooltip. I tried to copy/paste the formula instead of using the master measure but I always get '0' as result.
Yeah, this formula won't work in this context, I think - it's only evaluated once in the label, not per dimension value.