Forum Discussion
How can I sum value in a same column?
Hi All.
I want to add a column that sum values in a same column, bur I don't know how to do it.
What I want to do is add the row above and the row below each other.
It is easy in Excel, But I want to make it in Power BI for auto-update and publishing.
How can I add a column in Power BI just like Excel image below?
It's not easy because I'm a beginner. Thanks very much for your help!
Hi, Anonymous
It seems that what you want is just to add the previous value and the current value.
Are the dates in the table consecutive?Please try formula as below:
Calculated column:column = VAR _lastdate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] < EARLIER ( 'Table'[Date] ) ) ) VAR _lastunit = CALCULATE ( MAX ( 'Table'[Unit] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] = _lastdate ) ) VAR _currentunit = 'Table'[Unit] RETURN _lastunit + _currentunitBest Regards,
Community Support Team _ Eason
2 Replies
- johnt75Super User
You can add a running total column like
Running Total =
var currentDate = 'Table'[date]
return CALCULATE( SUM('Table'[unit]), REMOVEFILTERS('Table'[date]), 'Table'[date] <= currentDate ) - v-easonf-msftCommunity Support
Hi, Anonymous
It seems that what you want is just to add the previous value and the current value.
Are the dates in the table consecutive?Please try formula as below:
Calculated column:column = VAR _lastdate = CALCULATE ( MAX ( 'Table'[Date] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] < EARLIER ( 'Table'[Date] ) ) ) VAR _lastunit = CALCULATE ( MAX ( 'Table'[Unit] ), FILTER ( ALL ( 'Table' ), 'Table'[Date] = _lastdate ) ) VAR _currentunit = 'Table'[Unit] RETURN _lastunit + _currentunitBest Regards,
Community Support Team _ Eason