Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everybody!
I read some forum posts about "previous month". However, I was not successful in applying.
I have the following situation, I need to lock my Set Analys so that it always takes the previous month. My expression is like this:
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Monthstart(Today())-1)"}>}
DISTINCT NR_NUMERIC))
In this case you should transform output of MonthStart(Today(),-1) expression to MMM/YYYY format, your expressions are:
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Date(MonthStart(Today(),-1), 'MMM/YYYY'))"}>}
DISTINCT Value)
Based on today() function, today is 4/28/2022, Qlik will show the count for the previous month - Mar/2022 even if you select Feb/2022 in MESANO_PRIMDIA
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Date(MonthStart(Max(MESANO_PRIMDIA),-1), 'MMM/YYYY'))"}>}
DISTINCT Value)
Based on Max(MESANO_PRIMDIA), if the latest MESANO_PRIMDIA in your application is Apr/2022 Qlik will show the count for Mar/2022. If you select Mar/2022 Qlik will show data for Feb/2022
Regards,
Vitalii
Hi,
You can add '-1' as a second parameter to monthsstart function
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Monthstart(Today(),-1))"}>}
DISTINCT NR_NUMERIC))
Regards,
Vitalii
Thank you for reply, Vitalii.
However, even using the second argument the field still appears null for me in the display. The dimension that I am using MESANO_PRIMDIA. Do I need to put the -1" argument in the dimension as well?
What do you have in MESANO_PRIMDIA column?
In column, MESANO_PRIMDIA ,has the date in the format: "MMM/YYYY"
In this case you should transform output of MonthStart(Today(),-1) expression to MMM/YYYY format, your expressions are:
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Date(MonthStart(Today(),-1), 'MMM/YYYY'))"}>}
DISTINCT Value)
Based on today() function, today is 4/28/2022, Qlik will show the count for the previous month - Mar/2022 even if you select Feb/2022 in MESANO_PRIMDIA
COUNT({1<CD_SETOR={22},
MESANO_PRIMDIA={"$(=Date(MonthStart(Max(MESANO_PRIMDIA),-1), 'MMM/YYYY'))"}>}
DISTINCT Value)
Based on Max(MESANO_PRIMDIA), if the latest MESANO_PRIMDIA in your application is Apr/2022 Qlik will show the count for Mar/2022. If you select Mar/2022 Qlik will show data for Feb/2022
Regards,
Vitalii