Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
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)