Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
0li5a3a
Creator III
Creator III

Current selection plus the last 6 months in Line Chart

Hi all,

I need to create a Line Chart where I would like to show the current selection and the last months too.

COUNT({$<aaa= {'xxx',''}>} aaa) i used this for the current selection but I would like to display the data for the  last 6 months too.

Is this possible in set analysis?

Kind regards,

Constantin

1 Solution

Accepted Solutions
Anil_Babu_Samineni

May be this? I assume, You have Neat Date Format

COUNT({$<aaa= {'xxx',''}, DateField = {">= $(=Date(AddMonths(Max(DateField),-6))) <=$(=Date(Max(DateField)))"}>} aaa)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful

View solution in original post

7 Replies
Anil_Babu_Samineni

May be this? I assume, You have Neat Date Format

COUNT({$<aaa= {'xxx',''}, DateField = {">= $(=Date(AddMonths(Max(DateField),-6))) <=$(=Date(Max(DateField)))"}>} aaa)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

Can you provide more info or some sample data? 

Is the current selection also the date?  So you want all date from the currently selected date back 6 months?

Or some other dimension?  If some other dimension do you want that selection PLUS the last 6 months ignoring the selection?

0li5a3a
Creator III
Creator III
Author

Hi,

The current selection are year and months.

I want to select them and after my line chart to show  me the selection like year 2017 and month june plus 6 previews months.

Thank you

Anonymous
Not applicable

Then I think you need something very similar to what Anil provided.  Assuming you have a DateField too.

Something like:

COUNT({$<YourYearField=,YourMonthField=, DateField = {">= $(=Date(AddMonths(Max(DateField),-6))) <=$(=Date(Max(DateField)))"}>} aaa)

0li5a3a
Creator III
Creator III
Author

using the above code I achieved this, which is wrong

Capture.PNG

0li5a3a
Creator III
Creator III
Author

Thank for your answer but the above code doesn't work for me..

I created 2 columns like:

monthname(OrderDate) as CalendarPeriod

num(MonthName([OrderDate))  AS CalendarPeriodnum

plus I added this code to my expression :

count({$<aaa= {'xxx',''}, CalendarPeriodnum={'>= $(=num(MonthStart(AddMonths(max(CalendarPeriod),-5)))) <= $(=num(MonthEnd(max(CalendarPeriod))))'},D_InvCal.CalendarMonth=,D_InvCal.CalendarYear=>}aaa)

The problem is if I select year 2017 the data in line chart is not organised in the right position.

Please  check below.

Capture.PNG

0li5a3a
Creator III
Creator III
Author

Thank you all for your help.  I managed to fix the problem. I changed the dimension to be monthyear and now all is ok.