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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with set analysis, how to calculate 15 months sum?

Can someone help me out with this set analysis expression? I have a chart that needs to calculate sum of last 15 month shipments based on the ReturnYear and ReturnMonth for each part number. For example, if ReturnMonth and ReturnYear is Apr 2007, the chart should display sum of all shipments from Jan 2006 to Mar 2007. After searching extensively on the community, I tried this as suggested in one of the posts but not getting the desired results.

There are two tables:

Shipments:

LOAD ShipDate,
date( Monthstart(ShipDate), 'MMM YY') as ShippedMonth,
date( yearstart(ShipDate), 'YYYY') as ShippedYear,
shippedQuantity,
Part_num,
.....
......


Returns:

LOAD ReturnDate,
date( Monthstart(ReturnDate), 'MMM YY') as ReturnMonth,
date( yearstart( ReturnDate), 'YYYY') as ReturnYear,
.....
.....


I created a chart (straight table) with first dimension as Part_num, second dimension ReturnYear, third dimension as ReturnMonth. The expression should calculate Sum(TotalShipped) for last 15 months.This is the expression I tried but not giving me the desired results.

sum({<ReturnDate=,ReturnYear=,ReturnMonth={">$(=date(addmonths(max(ShippedMonth),-15),'MMM YY')) <=$(=date(max(ShippedMonth),'MMM YY'))"}>} shippedQuantity)

Please help. Should I be loading Month and year in a different way?

1 Reply
Not applicable
Author

Hi,

please see the attached example for help.

Good luck!

Rainer