Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

balajisj30
New Contributor III

Previous month using set analysis in qliksense

Hello people

I have created date field using this expression,

Date( MakeDate( left(acc_period,4) , right(acc_period,2) ) , 'YYYY-MM' )

I have a requirement to display previous month sales based on the selected Date. I used the below exp for previous month sales,

=Sum({$<Date={"$(=Max(Date)-1)"}>}sales)

But it is not working. Please help me to solve this issue.

Date format - YYYY-MM (2018-12)

1 Solution

Accepted Solutions
sasiparupudi1
Honored Contributor III

Re: Previous month using set analysis in qliksense

Sum({$<Date={"$(=Date(AddMonths(Max(Date),-1),'YYYY-MM'))"}>}sales)

4 Replies
krishna20
Valued Contributor

Re: Previous month using set analysis in qliksense

Hi ,

Derive a separate month field from your Date field and construct your expression .

sasiparupudi1
Honored Contributor III

Re: Previous month using set analysis in qliksense

Sum({$<Date={"$(=Date(AddMonths(Max(Date),-1),'YYYY-MM'))"}>}sales)

shubham_singh
Contributor II

Re: Previous month using set analysis in qliksense

Create a column named MonthSerial using


(num#( left(acc_period,4))*12) + num#( right(acc_period,2)) as MonthSerial



then use


=Sum({<MonthSerial={$(=(Max(MonthSerial)-1))}>}sales)


for previous month sales

balajisj30
New Contributor III

Re: Previous month using set analysis in qliksense

Thanks. Exp is working.