Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Sum all previous rows by column value

Greetings,

 

I need help with a formula. I'm new into DAX (Power BI), I've tried many solutions but none worked as intended.

 

I have this table in excel:

Row/LineABCD
1ItemQty. NeededStockMissing
2A210No
3A110No
4B37No
5A110No
6A210No
7B57No
8B17Yes
9A310No
10A410Yes
11A410Yes

 

In excel, I have a IF with SUM.IF, formula, lets consider we are looking at Missing column at line 5, it'll look like this:

 

IF(C5 < SUM.IF(A$1:A5 ; A5 ; B$1:B5) ; "Yes" ; "No")

 

This checks all rows until the one it is in. (So row 5 checks all rows until row 5)

It sums all "Qty. Needed" if the Item is equal to the Item in row 5.

If the sum is more than the Stock, writes "Yes", otherwise, "No".

 

I've tired using EARLIER, CALCULATE, SUMX, but I couldn't figure anything that would work. I hope someone more expirienced has a solution.

 

If you have any questions, I'm happy to try and reply them.

 

Thank you all.