Forum Discussion
aagj
6 years agoFrequent Visitor
Help with running total
Hi, I need the running total to start over for every new months, example: Date Sales cumulative total 01-01-2020 10 10 02-01-2020 20 30 03-01-2020 10 40 04...
- 6 years ago
Hi aagj ,
At first, you need to create a new column to get "YYYY-MM".
YM = FORMAT('Table'[Date],"yyyymm")Then you could use column or measure to get the running total.
Column:
Column = CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( 'Table', 'Table'[YM] = EARLIER ( 'Table'[YM] ) && 'Table'[Date] <= EARLIER ( 'Table'[Date] ) ) )Measure:
Measure = CALCULATE ( SUM ( 'Table'[Sales] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[YM] = MAX ( 'Table'[YM] ) && 'Table'[Date] <= MAX ( 'Table'[Date] ) ) )Here is my test file for your reference.
v-eachen-msft
6 years agoCommunity Support
Hi aagj ,
At first, you need to create a new column to get "YYYY-MM".
YM =
FORMAT('Table'[Date],"yyyymm")
Then you could use column or measure to get the running total.
Column:
Column =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
'Table',
'Table'[YM] = EARLIER ( 'Table'[YM] )
&& 'Table'[Date] <= EARLIER ( 'Table'[Date] )
)
)
Measure:
Measure =
CALCULATE (
SUM ( 'Table'[Sales] ),
FILTER (
ALLSELECTED ( 'Table' ),
'Table'[YM] = MAX ( 'Table'[YM] )
&& 'Table'[Date] <= MAX ( 'Table'[Date] )
)
)
Here is my test file for your reference.