Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I get the CurrentMonth variable in number form like this:
Set CurrentMonth = Num(Month(Date#(Month(Today()),'MMM')));
This variable can be used for displaying values and it works as it should, displays 10 if it's October.
However if I want to use this variable in the chart expression then it does not work. Compare the below two:
sum({$ < BillingMonth = {"<=10"}, BillingYear = {'2020'}> } Units)
Above expression works.
sum({$ < BillingMonth = {"<=$(CurrentMonth)"}, BillingYear = {'2020'}> } Units)
This one does not, it is evaluated as correct but returns 0, while the top one nicely returns sales for all months in the year 2020 that are equal or smaller than 10.
I also tried with double dollar, and again the expression is correct but returns 0.
sum({$ < BillingMonth = {"$(<=$(CurrentMonth))"}, BillingYear = {'2020'}> } Units)
or without double quotes
sum({$ < BillingMonth = {$(<=$(CurrentMonth))}, BillingYear = {'2020'}> } Units)
@alenb try to use floor instead num and also try to evaluate expression within variable using Let instead of set. Then you can use that variable in set analysis
Let CurrentMonth = floor(Month(Date#(Month(Today()),'MMM')));
@alenb try to use floor instead num and also try to evaluate expression within variable using Let instead of set. Then you can use that variable in set analysis
Let CurrentMonth = floor(Month(Date#(Month(Today()),'MMM')));
It was the "Let" vs "Set", thanks man! I'm a senior programmer but very new to Qlik and I think I will never get used to the differences between Let and Set 🙂