Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Break down Running Total into separate cases

Hello Everybody,

 

I've seen lots of explanations to create a running/accumulating total, however the raw data I have begins with a running total and I would like break this down to the value added on. Simple enough in Excel, I believe, but I would rather do it in BI. 

 

I am looking at California's Testing rate for COVID-19 and would like to create a Calculated Column called DailyNewTests:

 

Staja809_0-1595338346148.png

 

Which is to say, the first value would be 6291, the second would be 11487-6291 = 5196, the third would be 12528 - 11487 = 1041 and so on..

Would anyone be able to help me? Much appreciated! 

 

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code for a calculated column:

 

Column = 
VAR _previousDate = CALCULATE(MAX('Table'[Date]), FILTER('Table', 'Table'[Date] < EARLIER('Table'[Date])))
RETURN
     'Table'[Values] - CALCULATE(SUM('Table'[Values]), FILTER('Table', 'Table'[Date] = _previousDate))

 

Capture.PNG

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

If you have non continous date

column =
var _last_date =maxx(filter(Table,Table[Date] <earlier(Table[Date])),Table[Date])
return  Table[accumulated total]-maxx(filter(Table,Table[Date] =_last_date),Table[Date])

 

continuous Date

 

Total = Table[accumulated total]-maxx(filter(Table,Table[Date] =earlier(Table[Date])),Table[Date])

 

Refer this to have measures https://medium.com/@amitchandak.1978/power-bi-day-intelligence-questions-time-intelligence-5-5-5c3243d1f9

 

 

camargos88
Community Champion
Community Champion

Hi @Anonymous ,

 

Try this code for a calculated column:

 

Column = 
VAR _previousDate = CALCULATE(MAX('Table'[Date]), FILTER('Table', 'Table'[Date] < EARLIER('Table'[Date])))
RETURN
     'Table'[Values] - CALCULATE(SUM('Table'[Values]), FILTER('Table', 'Table'[Date] = _previousDate))

 

Capture.PNG

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors