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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
andre_bento
Contributor III
Contributor III

Calculating Previous period

I am trying to calculate the number of TEU's for the previous period. So if i select the month of March I want to see the number of TEU's for February. I created two variables min_date which gives me the first day of my selected range, and date_diff which gives me the number of days in my range, so if I select the month of March my min_date would be 01/03/2024 and my date_diff would be 31. I tried using the following expression to calculate my previous period: =({<[DATE.autoCalendar.Date]={">=$(=$(min_date) -$(date_diff)-1)))<=$(=$(min_date)-1))"}>} [TEU])
However I am getting the number of TEU's for the month of March and not for February. 

Labels (1)
3 Replies
Clement15
Partner - Specialist
Partner - Specialist

Hello, you can use this : 

{<month={"$(=month(AddMonths(max(Date),-1)))"}>}

 

You can use MonthName instead of Month depending on what you want

andre_bento
Contributor III
Contributor III
Author

Hello,

 

Screenshot 2024-04-04 at 14.51.34.png

That returns an error in expression.

Clement15
Partner - Specialist
Partner - Specialist

The formula I provided to you is just the set analysis, you must adapt it to your measure. Additionally, you need to change the field names to match your data