Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to display latest six month data in the graph??

Hi Experts

In my expression i am using

"sum(if(Date(month)>=Date(min(month)) and Date(month)<=Date(max(month)),Total))"  [includes Calendar object]

this will display the entine data between the min and max(allong with calendar object).

Now the deal is to display only the latest six month data so how can i proceed this changes in the above expression.

Many thanks in advance.

7 Replies
ashkrit501
Contributor II
Contributor II

Worth a try ?

"sum(if(Date(month)>=Date(max(month))-6 and Date(month)<=Date(max(month)),Total))"

jagan
Partner - Champion III
Partner - Champion III

Hi Madhu,

I think you have a date field in your datamodel, so you achieve this by using below expression

=Sum({<DateField={'>=$(=AddMonths(Max(DateField), -6))<=$(=Max(DateField))'}>} Sales)

AddMonths(Max(DateField), -6)  = This gives you the date by subtracting 6 months from the selected date.

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable
Author

Hi,

You'll also need to do some sorting of the months dimension, so that if you're showing last 6 months and the current month is before june the months wrap from dec round to jan. I did this by creating a MonthSort table linked to the Calendar table's month field, in which 12 columns read MonthSort1...12, as follows:

MonthMonthSort1MonthSort2MonthSort3MonthSort4MonthSort5MonthSort6MonthSort7MonthSort8MonthSort9MonthSort10MonthSort11MonthSort12
1112111098765432
2211211109876543
3321121110987654
4432112111098765
5543211211109876
6654321121110987
7765432112111098
8876543211211109
9987654321121110
10109876543211211
11111098765432112
12121110987654321

You can then determine the startmonth, e.g. Nov for 6 months to April, and then add [MonthSort$(StartMonth)] to the Sort by expression field.

Jonathan

Not applicable
Author

Hi Madhu,

I suggest that you can create Rolling Month Number and from that you can use max month ID - 6 to display the last 6 months data in the graph.

Thanks,

Srini.

Anonymous
Not applicable
Author

Thanks a lot yaar.. this is not reflecting the graph as well..

  "sum(if(Date(month)>=Date(max(month))-6"sum(if(Date(month)>=Date(max(month))-6

Anonymous
Not applicable
Author

Hi Jagan

By going with this month is showing lastest 6 month but while selecting calendar object this is not working

jagan
Partner - Champion III
Partner - Champion III

Hi Madhu,

You can ignore the calendar object selections by using MonthField=, YearField= like this exclude all date field in expression

Ex:

=Sum({<YearField=, MonthField=, QuarterField=, WeekField=, DateField={'>=$(=AddMonths(Max(DateField), -6))<=$(=Max(DateField))'}>} Sales)

Hope this helps you.

Regards,

Jagan.