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

Cumulative calculation script

Hello all. 

I'm looking to incorporate a cumulative average in the script.

My table looks in a very basic way like:

CustomerArticleDateSales_dateShipmentreceived_dateQtySoldQtyReceived
AA01-01-20 01-01-20 5
AA05-01-2005-01-20 2 
AA10-01-2010-01-20 1 
AA16-01-20 16-01-20 3
AA18-01-2018-01-20 4 
BA01-01-20 01-01-20 5
BA04-01-2004-01-20 3 
AB01-01-20 01-01-20 10
BB02-01-20 02-01-20 15

 

I'm trying to calculate the average stock level per date. The result should be something like this:

CustomerArticleDateSales_dateShipmentreceived_dateQtySoldQtyReceivedQtySold_CumulQtyReceived_CumulQty_stock_on_date
AA01-01-20 01-01-20 5 55
AA05-01-2005-01-20 2 253
AA10-01-2010-01-20 1 352
AA16-01-20 16-01-20 3385
AA18-01-2018-01-20 4 781
BA01-01-20 01-01-20 3 33
BA04-01-2004-01-20 2 231
AB01-01-20 01-01-20 10 1010
BB02-01-20 02-01-20 15 1515

 

So I would like to add rows for cumulative sales per customer per article and cumulative shipments received per customer per article.  These should be subtracted from each other defined by a time period (per date, or maybe week(date)). So I can get a stock average per week. So if I check the stock for 11-01-20 for customer A and article A it will show a stock level of 3. 

Is there a simple way of doing this?

Labels (5)
3 Replies
sunny_talwar

Where is Sales_date 18-01-20 with QtySold of 4 coming from? I don't see an entry within the input table?

hardleers
Contributor
Contributor
Author

Good noticed. These tables stay annoying layout wise. Updated for visibility. But do you have an idea? 

Brett_Bleess
Former Employee
Former Employee

Have a look at the following Design Blog post, not sure if it may help or not:

https://community.qlik.com/t5/Qlik-Design-Blog/The-As-Of-Table/ba-p/1466130

https://community.qlik.com/t5/Qlik-Design-Blog/Average-Which-average/ba-p/1466654

https://community.qlik.com/t5/Qlik-Design-Blog/Set-Analysis-in-the-Aggr-function/ba-p/1463822

If those fail, you can use the following link to search further yourself to see if anything you find may be better...

https://community.qlik.com/t5/Qlik-Design-Blog/bg-p/qlik-design-blog

Sorry I do not have something better for you.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.