Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
woody1982
Contributor III
Contributor III

Sum last month

Hello,

I have a formula that gives me the buzzer of the route for the current month:

sum({< Month = {"$(=month(today()))"} >} route)

this also works great. But now I want to output the last month.
Unfortunately, this does not work. I currently have the following formula:

sum({< Month = {"$(=month(Date(today())-31))"} >} route)

can anyone tell me what is wrong? Thanks a lot 🙂

6 Replies
Primrose
Contributor III
Contributor III

Hi, @woody1982 ,

You can use Addmonths(). For example, you can write something like sum({< Month = {"$(=month(AddMonths(today(),-1))"} >} route)

You can check Qlik Help for examples or maybe this post.

woody1982
Contributor III
Contributor III
Author

Hi,
Thanks, but even there it always shows only 0 and no values 😞

Primrose
Contributor III
Contributor III

Can you tell me what is the format of the values in the Month field?

woody1982
Contributor III
Contributor III
Author

it is Jan / Feb / Mrz...

Primrose
Contributor III
Contributor III

 If the sum({< Month = {"$(=month(today()))"} >} route) works for all months, the one with Addmonths() should work as well. Can you create a table with one column for Month (the field), one column with the Month(today())) and one column with month(AddMonths(today(),-1))? I suppose it's about month formatting.

woody1982
Contributor III
Contributor III
Author

month.PNG

Columns: 

1 - Month
2 - sum({< Month = {"$(=month(today()))"} >} route)
3 - Month(today())
4 - month(AddMonths(today(),-1))
5 - sum({< Month = {"$(=month(AddMonths(today(),-1))"} >} route)