Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I'm having an issue when trying to put an expression into a variable.
I have a text object with the following expression, giving the right number (production of last year before the current month) :
=Num(Sum({1<Year = {$(=v_YearReference-1)}, Month = {"<=$(v_MonthReference)"}, [_REF_DESC] = {"Actual"}, FACT_TYPE_ID={"PKG02"} >} [FACT_VALUE]), '# ##0')
I want to put this expression into a variable in order to have all expressions visible in the script and make maintenance easier. So I did the following in the script :
SET v_ProducedYTDPreviousYear = Num(Sum({1<Year = {$(=v_YearReference-1)}, Month = {"<=$(v_MonthReference)"}, [_REF_DESC] = {"Actual"}, FACT_TYPE_ID={"PKG02"} >} [FACT_VALUE]), '# ##0');
...and I put this in the text object :
=$(v_ProducedYTDPreviousYear)
My issue is that I now have 0 displayed in the text object, and I don't know why. Maybe it has something to do with SET/LET or the way I calculate the year and month, but I'm quite new to Qlikview and don't understand everything.
Note : There if I put =v_ProducedYTDPreviousYear, it shows the expression with Year={}.
Note2: The same expression works if I use $(v_YearReference) instead of $(=v_YearReference-1). What is the difference?
Thank you for your help
I found out what my issue was. I shouldn't have put my expressions in the script, but directly in the variable overview.
The difference :
- with the expressions in the script, the {$(=xxx)} inside the expression are calculated when executing the script.
- with the expressions in the variable overview, the whole expression is calculated at runtime, so {$(=xxx)} is too.