Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

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
MVP
MVP

Re: Show previous month data by expression

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)