Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
Not sure how to solve this, so not sure how to search for an answer.
Ive got several buttons, that sets a variable as a action. Button1 sets vProduct='Cars', Button2 sets vProduct='Boats' asf.
Now I want a bar chart to dynamic show the number of Products with a reclamation (I set a flag when loading the data).
date | _RecFlagCars | _RecFlagBoats |
---|---|---|
2017-06-01 | 1 | 0 |
2017-06-02 | 1 | 0 |
2017-06-04 | 0 | 1 |
2017-06-04 | 0 | 0 |
2017-06-06 | 0 | 1 |
When Button1 is pressed the barchart should only show 'sum(_RecFlagCars)' (with date as dimension).
Id like to use the variable that I use on the Button1 to change the ending om '_RecFlag', something like this;
"Sum({<Week={=$(vCurrWeek)}>} _RecFlag" & vProduct & "')"
I've tried using a inline-table like this;
Value, expression
Cars, Sum({<Week={=$(vCurrWeek)}>} _RecFlagCars)
Boats, Sum({<Week={=$(vCurrWeek)}>} _RecFlagBoats)
But when I look at expression it shows "Sum({<Week={}>} _RecFlagCars", of some reason it dont like the variable in there
Does anyone have any idea how to solve this?
No, I mean on the barcharts when trying to change the expression between _RecFlagCars and _RecFlagBoats.
If($(vProduct)='Cars', Sum({<Week={=$(vCurrWeek)}>} _RecFlagCars ), Sum({<Week={=$(vCurrWeek)}>} _RecFlagBoats) )
Hi,
why don't you simply use an If to solve this ?
You mean on the buttons when I assigning the variable?
No, I mean on the barcharts when trying to change the expression between _RecFlagCars and _RecFlagBoats.
If($(vProduct)='Cars', Sum({<Week={=$(vCurrWeek)}>} _RecFlagCars ), Sum({<Week={=$(vCurrWeek)}>} _RecFlagBoats) )
The problem is that the $ expansion is happening inside the inline load, so it is attempting to substitute $(vCurrWeek) with the value of vCurrWeek - which is probably undefined at that point. If you load from a text file or spreadsheet, the $ expansion will not take place. In an inline, you will need to delay the expansion. This is one way
LOAD
Value,
Replace(expression, '#', '$') as expression
Inline
[
Value, expression
Cars, Sum({<Week={=#vCurrWeek)}>} _RecFlagCars)
Boats, Sum({<Week={=#(vCurrWeek)}>} _RecFlagBoats)
];
ofcourse, stupid me. Works like a charm!
This work to, but with the IF-statement theres no need for a inline-load.
Could be useful in other scenarios aswell so Ill keep it in mind.
Thanks!