Forum Discussion
DAX Running total by another column
- 10 years ago
Hello nhanser,
for me it looks like you want to add a calculated column, but the DAX code you use is for beeing used in a pivot table.
I copied your raw data, but used different dates.
The pivot I created looks like this and I hope this is what you want:
The code I used is close to the one you used, but slightly different:
RunningTotal :=
CALCULATE (
SUM ( Tabelle1[QTY] );
FILTER ( ALL ( Tabelle1 ); Tabelle1[Date] <= MAX ( Tabelle1[Date] ) );
VALUES ( Tabelle1[Item] )
)The key here is the VALUES() which puts the Items into the filter context of the CALCULATE()-statement. Otherwise you would have running totals on the dates, but it would be the same for all your Items.
Hope that helps a bit.
Greets,
Lars
Hi robbie337 did you find a solution to your problem?
I have a similar problem, since I want to display my Running Total Measure in a Line Chart and I need to to filter on different categories in a slicer.
If I include my VALUES[Category column] in the Running Total Measure all is fine as long as I ALWAYS have one of the Categories selected in my slicer. If I deselect all in the Category Slicer the Line Chart will jump up and down and not continue to increase as intended.
To fix this I can just leave out the VALUES([Category column] of my Running Total Measure, but then my Running Total would just show an aggregation across all categories and not calculate PER category as intended.
...This is such an easy task in Excel Pivot Tables where Running Total Calculation is a standard option - why is this still missing in PowerBI.