Forum Discussion
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/Line | A | B | C | D |
| 1 | Item | Qty. Needed | Stock | Missing |
| 2 | A | 2 | 10 | No |
| 3 | A | 1 | 10 | No |
| 4 | B | 3 | 7 | No |
| 5 | A | 1 | 10 | No |
| 6 | A | 2 | 10 | No |
| 7 | B | 5 | 7 | No |
| 8 | B | 1 | 7 | Yes |
| 9 | A | 3 | 10 | No |
| 10 | A | 4 | 10 | Yes |
| 11 | A | 4 | 10 | Yes |
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.
- Anonymous5 years ago
the rules of calculation and comparison are not entirely clear to me. But maybe this is what you are looking for
1 Reply
- AnonymousNot applicable
the rules of calculation and comparison are not entirely clear to me. But maybe this is what you are looking for