Forum Discussion
Gpensabene
6 years agoFrequent Visitor
Cumulative Total on Result Table
Hi,
I am trying to include a column for cumulative sum in Power BI table visual.
Obviously the following version is a simplified scenario compared to the complex case I am implementing.
Sample table
| Code | Qty |
| A | 1 |
| A | 1 |
| B | 1 |
| C | 1 |
| A | 1 |
| D | 1 |
| E | 1 |
| B | 1 |
| B | 1 |
| B | 1 |
| B | 1 |
Result table without Cumulative total (order by Qty descending)
| Code | Qty |
| B | 5 |
| A | 3 |
| C | 1 |
| D | 1 |
| E | 1 |
DAX formula the I use at the moment
Running Total MEASURE = CALCULATE (
SUM ( Tabella[Qty] );
FILTER (
ALLSELECTED( Tabella );
Tabella[Qty] <= MAX ( Tabella[Qty] )
)
)
The "Running Total MEASURE" shows a Sum of all rows because the Qty is the same, I have add the column with the Expected values
| Code | Qty | Running Total MEASURE | Expected values |
| B | 5 | 11 | 5 |
| A | 3 | 11 | 8 |
| C | 1 | 11 | 9 |
| D | 1 | 11 | 10 |
| E | 1 | 11 | 11 |
Any help would be greatly appreciated.
Regards,
Hi Gpensabene
Sorry should have a reference table and not duplicate, please see the attached.
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
5 Replies
- Mariusz
Community Champion
Hi Gpensabene
Please see the attached file with a solution
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn
- GpensabeneFrequent Visitor
Hi Mariusz
It is not work, you have add an hardcoded table with the current order.
I added new records at 'A'
expected
Code Qty Expected values A 8 8 B 5 13 C 1 14 D 1 15 E 1 16 Thanks for the attempt
- Mariusz
Community Champion
Hi Gpensabene
Sorry should have a reference table and not duplicate, please see the attached.
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.
Please feel free to connect with me.
LinkedIn