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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Show previous month data by expression

Hi,

I am trying to write an expression that will show the previous month's data of sales.

I have been able to use this formula to show the previous years sales in another table

Sum({<Year={'$(=Year(Today())-1)'}>}Sales)

But when I replace Year with Month it does not bring back any values.

Thanks for helping!

1 Reply
sunny_talwar

Create a new field in the script like this

LOAD Date,

    Year(Date) as Year,
    Month(Date) as Month,

   Date(MonthStart(Date), 'MMMYYYY') as MonthYear

FROM ...

And then try this

Sum({<MonthYear={"$(=Date(MonthStart(Max(MonthYear), -1), 'MMMYYYY'))"}, Year, Month>}Sales)