Forum Discussion
klod78
6 years agoFrequent Visitor
Running Total
I am trying to calculate the running total, but it is not working as I want. If you look at the pictures below, it works if I don't apply any filter, but if for instance I want to see the data for 20...
- 6 years ago
My guess would be to use ALLSELECTED, instead of ALL https://docs.microsoft.com/nl-nl/dax/allselected-function-dax
- 6 years ago
klod78 , Try like
Running total =
CALCULATE (
SUM('Sheet1 (2)'[Count]);
FILTER(
ALLselected('Sheet1 (2)' );
'Sheet1 (2)'[IntrDate] <= MAX('Sheet1 (2)'[IntrDate])
)
)
AntrikshSharma
6 years agoCommunity Champion
Here is a running total pattern:
Running Total =
VAR MaxDateInFilterContext =
MAX ( Dates[Date] )
VAR MaxYear =
YEAR ( MaxDateInFilterContext )
VAR DatesLessThanMaxDate =
FILTER (
ALL ( Dates ),
Dates[Date] <= MaxDateInFilterContext
&& Dates[Calendar Year Number] = MaxYear
)
VAR Result =
CALCULATE (
[Total Sales],
DatesLessThanMaxDate
)
RETURN
Result