Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Vintageologist
Contributor
Contributor

Cumulative Sum of order quantities using rangesum and/or above not working

Hello,

I have a production board where I would like to predict future stock inventories for the production department to understand what the required output will be.

The existing dimensions and measures are:

Article
Order Number
Delivery Date
Current Stock (this is one fixed value per Article coming from the inventory system)
Stock Date (again one value per Article, last time the amount Current Stock was updated)
Order Amount (this is the quantity - a value per Order, Article and Delivery Date)

There are also a number of other dimensions in the table not related to the calculation (such as product size) but leading me to require the TOTAL qualifier so the calculation sections aren't broken (I think).

Now I would like to calculate two dimensions in a table:
Stock Before Delivery and Stock After Delivery (the latter just being the former minus the current order amount).

Stock Before Delivery should be the (fixed) Current Stock minus all orders (Order Amount) of that product that come before the current row that are of the same Article, earlier or same Delivery Date and - if the Delivery Dates are the same - smaller Order Number.

I have already tried countless variations of Above, Rangesum, Sum etc to no avail...

The below appears to "almost" work but I can't get it to use only those amounts that are of the same article and with a delivery date greater than the stock date (i.e. it works if I remove the Article set analysis but then also sums other products).
Also, if I use RowNo() instead of 999, it sums only within the same Delivery Date despite TOTAL:

alt([Current Stock],0) //Should start from the Current Stock or place 0 if it's null.
-

Rangesum(
     above(
           TOTAL sum(
                                   {$<
                                       [Delivery Date]={">$([Stock Date])"}
                                       ,Article={">$([Article])"}
                                      >}[
                              Order Amount])
       ,1,999)

)

 

Below you can see what I would like to achieve:


table.png

 

 

 

Thank you!

Labels (1)
0 Replies