Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
BI & Data Trends 2021. Discover the top 10 trends emerging in today. Join us on Dec. 8th REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

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
Highlighted
Master III
Master III

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

View solution in original post

5 Replies
Highlighted
Specialist II
Specialist II

Hi ,

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

Highlighted
Master III
Master III

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

View solution in original post

Highlighted
Partner
Partner

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

Highlighted
Creator
Creator

Thanks. Exp is working.

Highlighted
Contributor III
Contributor III

What is acc_period in your equation?