Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
lzanetti
Contributor III
Contributor III

Rolling sum on Qlik Sense

Hi all,

I need to build a "rolling sum" plot (or table as well), i. e. a sum that month by month runs on the latest 12 months.

More precisely, I have a graph that shows a variable (the number of sold products) month by month.

The other variable I want to show is the sum of sold products on one year up to that month.

The result should be a plot showing (month by month) the units sold in that month (e.g. March 2017) and the units sold on one year that far (e.g. April 2016 - March 2017).

I hope the request is clear.

Any help would be very appreciated.

Thanks, LuigiZ

35 Replies
OmarBenSalem

and please refer to this thread:

YTD, MTD issue

where I tried to explain step by step some of the basc time functions in Qlik !

Hope these could help you Luigi !

Omar BEN SALEM

lzanetti
Contributor III
Contributor III
Author

@Aehman

I want the sales over 12 month, up to the indexed month by default. The, if I select a product, he plot should show sales restricted to that product.

It's neither about sales of PYTD, nor sales YTD, it's sales on 12 months backwards.

A sample data looks like this:

  

QuantityPosting DateProduct
331/07/2017prod A
2028/07/2017prod A
5028/07/2017prod A
428/07/2017prod A
927/07/2017prod A
726/07/2017prod B
326/07/2017prod B
1626/07/2017prod B
424/07/2017prod B
3021/07/2017prod C
521/07/2017prod C
519/07/2017prod C
718/07/2017prod C
5418/07/2017prod A
618/07/2017prod A
118/07/2017prod A
118/07/2017prod B
204/07/2017prod B
121/07/2017prod C
113/07/2017prod C
7529/07/2017prod D
4028/07/2017prod D
528/07/2017prod D
528/07/2017prod D
627/07/2017prod D
126/07/2017prod B
326/07/2017prod B
526/07/2017prod B

for monthly sold product:

DIMENSION: PostingDate.autoCalendar.YearMonth

MEASURE: Sum(Quantity)

I need to create a measure for the "Products on market" sold over 12 months backwards, month by month:

lzanetti
Contributor III
Contributor III
Author

@omar bensalem, the "Calculating rolling n-period totals, averages or aggregations" looks fine, I read it earlier, but it's referred to Qlik View. How do I translae it to Qlik Sense?

all the proposed formulas don't work

OmarBenSalem

The example above has been implemented with Qlik Sense; (the example with my proper master calendar)

You should have tested it... I even attached an image to show you it does what you want to achieve

lzanetti
Contributor III
Contributor III
Author

omarbensalem‌ I read your explanation on syntax and it made a lot of light, thank you very much.

unfortunately, I'm still not able to get what I need.

lzanetti
Contributor III
Contributor III
Author

Ok, I didn't test it because I don't know where to paste alla that code.

agigliotti
Partner - Champion
Partner - Champion

Hi Luigi,

For your request you should use below expression:

=sum( {< Date = {">=$(=MonthStart(AddMonths(Today(), -12)))<=$(=MonthEnd(AddMonths(Today(), -1)))"} >} Amount )

what above for time period: nov '16 - oct '17

lzanetti
Contributor III
Contributor III
Author

Hi Andrea, I saw your reply, it looks fine, but it gives me all 0 as a result.

The same result I get from

sum({<Date.Autocalendar.YearMonth=,Date.Autocalendar.Year=,Date.Autocalendar.Month=,Date.Autocalendar.Date=,

Date.Autocalendar.Month={">=$(=addMonths(max(Date.Autocalendar.Date),-12))<=$(=max(Date.Autocalendar.Date))"}>}Quantity)


proposed by Omar.


One problem I realized I had, in the meanwhile, was: my field's name was "Posting Date" so in uploading to QS it became "Posting.Date" this made confusion I guess (because Date was recognized as a function).

I changed it to PostingDate


agigliotti
Partner - Champion
Partner - Champion

Hi Luigi,

At this point I think the quickest way to fix it is posting a sample qvf file.

lzanetti
Contributor III
Contributor III
Author

How can I get it?

I'm using QS Desktop