
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How to get previous month date ?
Hello,
How I can get previous month date when the user select a specific date?
My data has reporting date column. This reporting date column will have
- mid month date which is every 15th of the month
- month end date of the month
My user would like to compare the sales of the date selected with the previous month date.
So,
- when they select 15th June , they will see 15th May for the comparison.
- when they select 30th June, they will see 31st May for the comparison.
I have managed to get for the mid month but when it comes to the month end, it will show me the exact date but not the exact date of the previous month end date.
- when they select 30th June, they see 30th May instead of 31st May
How I can fix and make set analysis for this?
This is my current set analysis
- sum({<[Reporting Date.MasterCalendar.Date]={"$(=date(addmonths(vLatestDate,-1)))"}>}[Past Due])
- vLatestDate variable = date(max([Reporting Date.MasterCalendar.Date]
Help is much appreciated.
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set the AddMonths third "mode" parameter to 1.
addmonths(vLatestDate,-1, 1)
=AddMonths('6/30/2022',-1, 1) = 5/31/2022
See the help for AddMonths:
https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeF...
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the dynamic expression for the same period last month
=AddMonths(Max(Date), -1)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey,
Thank you.
But, I am using the suggested formula currently which is not fulfilling what I am looking for.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you provide specifics as to why it's not working for you or possibly give sample data?


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Set the AddMonths third "mode" parameter to 1.
addmonths(vLatestDate,-1, 1)
=AddMonths('6/30/2022',-1, 1) = 5/31/2022
See the help for AddMonths:
https://help.qlik.com/en-US/sense/August2022/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeF...
-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com
