I have such a prosaic problem. How do I create a variable that will contain the month in the form "YYYY/MM"?
I have let xxx = peek ('abc') where abc is the month in the correct format. But a variable divides two numbers by itself instead of keeping them as text. I also tried SET instead of LET but then peek doesn't work.
I am not sure if I understand what you want to achieve.
Do you have only month as field in your data model? If you also have a date, you could well extract "YYYY/MM" from the date field and then create a variable to contain that new field (ex: YearMonth)
year(Date) & '/' & Month(Date) as YearMonth
In the data model, I have exactly what you wrote.
Now I want to save this month (exactly in the same form) in a variable. Now the variable assigns me, for example, 168.4166666666667 (So the result of the division) instead of 2021/12.
Hi @qlikeers ,
I just did a quick check using set vMonth = YearMonth; in the script and the result is as expected
the result is displayed in "text &image" object.
Which version of Qlik sense are you using?
Can you share your sample QVF?
Hi @qlikeers ,
To make it easy, share your qvf (make it very sample, few lines in scripts + 1 sheet showing the value-result of used variable).
I am not sure to check it directly because I am busy today.
I don't really know how to do it, because I don't have access to disk space.
But here I really wrote everything 🙂
In the code:
date (num (AddYears (date (Max (% JOIN_InvoiceDate)), 0)), 'YYYY / MM') as% Curr_Month,
let vCurrMonth = peek('%Curr_Month');
In this case, the variable holds the result of dividing the year by the month (e.g. 168.416666 as the result of dividing 2021/12), instead of the string '2021/12'.