Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi!
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.
Where and how are you using this variable? If you are using it in the front end - try using it without $ expansion, or with single quotes around the dollar expansion.
vCurrMonth or '$(vCurrMonth)'
Hi,
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)
------- ex
Load *,
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?
Regards
Sorry!
I just noticed that you are using for example numeric 12 as month instead of text "Dec". Did you used dual() in your script?
Please share your sample qvf
/joseph
No, I didn't use dual. How do I get this to work?
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.
/joseph
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,
(...)
And then:
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'.
Where and how are you using this variable? If you are using it in the front end - try using it without $ expansion, or with single quotes around the dollar expansion.
vCurrMonth or '$(vCurrMonth)'
Of course!
'$(vCurrMonth)' - it works fine. Thanks @tresesco!