Forum Discussion
jdw_msft
1 year agoFrequent Visitor
Getting sum from cumulative table
Hello everyone, i have a sample table like this picture: I'll describe the table columns: date : obviously date sales: sold thing sales_running_sum: this is for monthly sales, reset to 0 every m...
- 1 year ago
Hi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
Sales MTD: = VAR _t = FILTER ( ADDCOLUMNS ( ALL ( 'date'[date], 'date'[Year], 'date'[Month], 'date'[Day] ), "@sales", [Sales:] ), 'date'[Year] = MAX ( 'date'[Year] ) && 'date'[Month] = MAX ( 'date'[Month] ) && 'date'[date] <= MAX ( 'date'[date] ) ) RETURN SUMX ( _t, [@sales] )Sales YTD: = VAR _t = FILTER ( ADDCOLUMNS ( ALL ( 'date'[date], 'date'[Year], 'date'[Month], 'date'[Day] ), "@sales", [Sales:] ), 'date'[Year] = MAX ( 'date'[Year] ) && 'date'[date] <= MAX ( 'date'[date] ) ) RETURN SUMX ( _t, [@sales] )
Jihwan_Kim
1 year agoSuper User
Hi,
I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file.
Sales MTD: =
VAR _t =
FILTER (
ADDCOLUMNS (
ALL ( 'date'[date], 'date'[Year], 'date'[Month], 'date'[Day] ),
"@sales", [Sales:]
),
'date'[Year] = MAX ( 'date'[Year] )
&& 'date'[Month] = MAX ( 'date'[Month] )
&& 'date'[date] <= MAX ( 'date'[date] )
)
RETURN
SUMX ( _t, [@sales] )
Sales YTD: =
VAR _t =
FILTER (
ADDCOLUMNS (
ALL ( 'date'[date], 'date'[Year], 'date'[Month], 'date'[Day] ),
"@sales", [Sales:]
),
'date'[Year] = MAX ( 'date'[Year] )
&& 'date'[date] <= MAX ( 'date'[date] )
)
RETURN
SUMX ( _t, [@sales] )