Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

show last 12 month information based on month selected in filter

Hi,

I've month and date field in my application, now my requirement is if is select October as month in filters and 2022 in year filter it has to show last 12 month information in a bar chart, means from oct-2021 till sep-2022 as different bars and in the same way if is select June as month in filters and 2022 in year filter it has to show last 12 month information in a bar chart, means from Jun-2021 till may-2022 in different bars.

Regards,

Vikas

@sunny_talwar , @PrashantSangle 

8 Replies
hic
Former Employee
Former Employee

Try the following set expression in your bar chart:

{<Year=,Month=,Date={">$(=AddMonths(Max(Date),-12))<=$(=Date(Max(Date)))"}>}

vikasshana
Creator II
Creator II
Author

thanks for that @hic  and it working as I expected, in my app I've data from 2021 Jan until Dec 2022. If I select May from Month and 2022 from year I can able to pull the details from June 2021 until May 2022. If I Don't select anything any thing I see information from Jan 2022 till Dec 2022 but I would like to see information from Jan 2021 until current month (i.e. July 2022).

hic
Former Employee
Former Employee

Try

{<Year=,Month=,Date={">$(=If(GetSelectedCount('Month')>0,MakeDate(1900),AddMonths(Max(Date),-12)))<=$(=Date(Max(Date)))"}>}

vikasshana
Creator II
Creator II
Author

displaying same result, no change.

PrashantSangle

Try

{<Year=,Month=,Date={">$(=If(GetSelectedCount('Month')>0,AddMonths(Max(Date),-12)))<=$(=Date(Max(Date))),

Date(monthstart(today(),-12))<=$(=Date(monthstart(Today ()))

"}>}

 

 

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
vikasshana
Creator II
Creator II
Author

Not working as well.

vikasshana
Creator II
Creator II
Author

Can some one help me to achieve this.

PrashantSangle

@vikasshana , can you explain little bit more about not working?

In my solution, I suggest if nothing is select then it will show previous 12 months data. You can modify it as per your requirement. so for example you confirm with that if nothing is selected then it will show from Jan 2021 to till current month then you can modify else part as per your requirement like

Try

{<Year=,Month=,Date={">$(=If(GetSelectedCount('Month')>0,AddMonths(Max(Date),-12)))<=$(=Date(Max(Date))),

Date(Date#('1-1-2021','DD-MM-YYYY'))<=$(=Date(monthstart(Today ()))

 

Regards,

Prashant Sangle

"}>}

Great dreamer's dreams never fulfilled, they are always transcended.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂