Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Last 2 months with current selected month

Hi,

I want last two months along with current selected month in bar chart.

like selected month is Jan and year is 2018. so i want Jan 2018, Dec 2017, Nov 2017.

I have separate year field and separate month field and i am using set analysis but not getting what i want.

Please help.

Thanks

6 Replies
YoussefBelloum
Champion
Champion

Hi,

Create a MonthYear field and use this expression:

sum({< MonthYear={">=$(=AddMonths(max(MonthYear),-3)) <=$(=max(MonthYear))" }>} your_measure)

zebhashmi
Specialist
Specialist

I second

driving from Selection use this.

sum({< MonthYear={">=$(=(MonthYear-2)) <=$(=MonthYear)" } >}your_measure)

Thanks

YoussefBelloum
Champion
Champion

Hi,

MonthYear field is Month&Year concatenated field

So, for 012018 for example, MonthYear -2 = 012016

zebhashmi
Specialist
Specialist

Yes Thanks!

so he just have to remove Max to drive it from Selection.

YoussefBelloum
Champion
Champion

You make me think, here is the new (tested) one:

sum({< MonthYear={">=$(=Date(AddMonths(Date#(MonthYear,'MMYYYY'),-2),'MMYYYY')) <=$(=Date(Date#(MonthYear,'MMYYYY'),'MMYYYY'))" }>} your_measure)

zebhashmi
Specialist
Specialist

Sounds good! Should be Marked Correct Answer Thank You for Sharing