Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Michael_Chappell
Contributor III
Contributor III

Help with Last Calendar Month

Hello and a Happy New Year to everyone! 🙂

We have an expression set up for Last Calendar Month (LCM) already, although it doesn't seem to be working correctly since we have now moved into the New Year. We would expect the results to show December although it is just showing January's current sales. See below for the LCM script;

IF( (Month([Date]) = Month (Today()-1)-1), 'Y', Null())

AS IsLCM,

Any and all help would appreciated!

Labels (3)
4 Replies
Or
MVP
MVP

Use AddMonths() rather than month subtraction, since January = 1 and subtracting 1 from 1 results in 0, not 12.

 

Michael_Chappell
Contributor III
Contributor III
Author

Hi Or,

Thank you for your help. That makes sense, although I'm not sure how to implement this? What I have tried comes up as an error.

Or
MVP
MVP

Perhaps something along the lines of:

If(MonthName(Date) = MonthName(AddMonths(Today()-1,-1),'Y')

vikasmahajan

if(monthstart([Date])=monthstart(Today()) and [Date] >=Today(),1,0 ) as Flag_MTD

Use this flag in set analysis

 

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.