Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I have faced a problem I cannot solve myself. I want to toggle the expression in chart to show unit or value based on listbox selection. Everything works fine unless I add comparison to the previous year. Only than the expression is not changed for previous year periods that have no corresponding figures this year.
this is my script:
LOAD
left(period,4) as rok,
right(period,2) as tydzien,
unit,
value
INLINE [
period, unit, value
202001, 201, "558,78"
202002, 202, "561,56"
202003, 203, "564,34"
202004, 204, "567,12"
202005, 205, "569,9"
202006, 206, "572,68"
202007, 207, "575,46"
202008, 208, "578,24"
202009, 209, "581,02"
202010, 210, "583,8"
202101, 211, "586,58"
202102, 212, "589,36"
202103, 213, "592,14"
202104, 214, "594,92"
];
LOAD * INLINE [
F1
u
v
];
When 'u' is selected the Year-1 expression is changed only for weeks 01-04 while weeks 05-10 remains values.
Any idea for workaround? Thanks in advance.
you can create a variable to hold the measure:
vMeasure: =if(only(F1)='u','unit','value') //this will return the field/measure you want to sum
in your expression:
=sum({.....}$(vMeasure)) //the variable will resolve to the desired measure.
depending on the measure you select, it will use the appropriate field:
you can create a variable to hold the measure:
vMeasure: =if(only(F1)='u','unit','value') //this will return the field/measure you want to sum
in your expression:
=sum({.....}$(vMeasure)) //the variable will resolve to the desired measure.
depending on the measure you select, it will use the appropriate field:
Thanks Edwin. It works as expected. 😁
One thing bothers me however. Why my initial if-based approached turned not to be working? Is it a QV bug?
i dont see anything wrong with the expression (although using an if statement in your expression is slower than not using it.) maybe you can attach your qvw as something else is going on