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

Subtraction from multiple rows

Hi community.

Is it possible to subtract a sum, e.g. 525, through several subtotals from several different rows in a table? The sum per row must not be negative.

DateQtyQty OUT
2019-04-13670
2019-04-20710
2019-04-191030
2019-04-211130
2019-04-2218312

 

I really appreciate all the help I can get.

1 Solution

Accepted Solutions
zhadrakas
Specialist II
Specialist II

here is a sample  that should do it:

TEST:
LOAD * INLINE [
Date, Qty, Qty OUT ,Capacity
2019-04-13, 67, 0, 525
2019-04-20, 71, 0 ,525
2019-04-19, 103, 0 ,525
2019-04-21, 113, 0 ,525
2019-04-22, 183, 12 ,525
]
;

sample.png

Sort by Date ascending

here are the Expressions:
suM(Qty)
suM(Capacity)
RangeSum(Above(TOTAL Sum(Qty), 0, Rowno(TOTAL)))
[Cap Total] - [Qty kum]

regards
tim

 

 

 

 

 

View solution in original post

4 Replies
zhadrakas
Specialist II
Specialist II

can you explain that step by step what you want to achieve?
annanirvin
Contributor III
Contributor III
Author

It's a bit difficult to explain but I'll try 🙂

If we have 67 applications with start date 2019-04-13, 71 applications with start date 2019-04-20 etc. according to my example and I know that we have the capacity to handle 525 of them and that the oldest start date is handled first, I want to be able to calculate both the oldest start date for the remaining applications and how many applications remain.

(My example is simplified, in reality the volumes are considerably larger.)

zhadrakas
Specialist II
Specialist II

here is a sample  that should do it:

TEST:
LOAD * INLINE [
Date, Qty, Qty OUT ,Capacity
2019-04-13, 67, 0, 525
2019-04-20, 71, 0 ,525
2019-04-19, 103, 0 ,525
2019-04-21, 113, 0 ,525
2019-04-22, 183, 12 ,525
]
;

sample.png

Sort by Date ascending

here are the Expressions:
suM(Qty)
suM(Capacity)
RangeSum(Above(TOTAL Sum(Qty), 0, Rowno(TOTAL)))
[Cap Total] - [Qty kum]

regards
tim

 

 

 

 

 

annanirvin
Contributor III
Contributor III
Author

Neat! That's exactly what I want. Thanks a lot!

Best regards
Anna