Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
oscarvictory
Contributor III
Contributor III

Accumulative sum leaser or first greater than value

Hi all, maybe you can help me out with this question.

Here is my table from SQL:

Table_1.jpg

and what I need is to display only the rows where ACUM sum includes STOCK amount:

Table_2.jpg

 Many TKS in advance.

Labels (1)
11 Replies
Kushal_Chawda

@oscarvictory  try below. Highlighted in Green you can replace it with measure you want to show. Suppose you want to show ACCUM , so replace it with below

sum(aggr(rangesum(above(total Sum(Qty),0,RowNo())), PRODUCT,(RCV_DATE,(NUMERIC,DESCENDING))))

 

=if(aggr(rangesum(above(total Sum(Qty),0,RowNo())), PRODUCT,(RCV_DATE,(NUMERIC,DESCENDING))) <= min(total <PRODUCT>aggr(if(rangesum(above(total Sum(Qty),0,RowNo())) > = sum(STOCK),rangesum(above(total Sum(Qty),0,RowNo()))), PRODUCT,(RCV_DATE,(NUMERIC,DESCENDING)))),
Sum(Stock),0)

oscarvictory
Contributor III
Contributor III
Author

Well, finally I add an equal to the comparison symbol and it worked as expected!!

Thank you very much!!

 

=if(aggr(rangesum(above(total Sum(Qty),0,RowNo())), PRODUCT,(RCV_DATE,(NUMERIC,DESCENDING))) <= min(total <PRODUCT>aggr(if(rangesum(above(total Sum(Qty),0,RowNo())) > = sum(STOCK),rangesum(above(total Sum(Qty),0,RowNo()))), PRODUCT,(RCV_DATE,(NUMERIC,DESCENDING)))),
Sum(Stock),0)