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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
jdearinger
New Member

Help: Building a deposit/withdrawal Calculation

I've been racking my brain around this and thought that I would ask the general community.

 

Use Case

There are manual deposits and withdrawals into tanks and what we're attempting to build is something that show a running total of how much should be in the tank when we measure it.

 

Example

Screen Shot 2017-04-27 at 11.14.04 AM.png

Explaination

The "Starting Level" is yesterday's "End Level".  Deposits and and withdrawals are then recalculated for that day by using the math of (("Starting Level" + "Deposits") - "Withdrawal") = "End Level"

 

When I attempt to do this I get a circular logic error, which makes sense, but maybe I'm just looking at this through the wrong lens.  

 

Is there any way to do this?

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@jdearinger,

 

Based on your description, it seems that you need to get the runngint total to previous day for starting level, and runngint total to current day for end level. You can use the DAX below to create your measure.

Starting Level = CALCULATE(SUM(Table1[Deposit])-SUM(Table1[Withdrawal])+100,FILTER(ALL(Table1[Date]),Table1[Date]<MAX(Table1[Date])))
End Level = CALCULATE(SUM(Table1[Deposit])-SUM(Table1[Withdrawal])+100,FILTER(ALL(Table1[Date]),Table1[Date]<=MAX(Table1[Date])))
Capture.PNG

 

Reference
http://www.daxpatterns.com/cumulative-total/

 

Regards,

Charlie Liao

View solution in original post

2 REPLIES 2
v-caliao-msft
Microsoft Employee
Microsoft Employee

@jdearinger,

 

Based on your description, it seems that you need to get the runngint total to previous day for starting level, and runngint total to current day for end level. You can use the DAX below to create your measure.

Starting Level = CALCULATE(SUM(Table1[Deposit])-SUM(Table1[Withdrawal])+100,FILTER(ALL(Table1[Date]),Table1[Date]<MAX(Table1[Date])))
End Level = CALCULATE(SUM(Table1[Deposit])-SUM(Table1[Withdrawal])+100,FILTER(ALL(Table1[Date]),Table1[Date]<=MAX(Table1[Date])))
Capture.PNG

 

Reference
http://www.daxpatterns.com/cumulative-total/

 

Regards,

Charlie Liao

Anonymous
Not applicable

You should consider simply NOT adding calculated columns for Starting/Ending levels.

 

If you only had Date, Deposits, Withdrawls in the table, and a separate storage for initial starting level... the rest can be calculated in measures.

 

Current Balance := [Initial Balance] + CALCULATE(SUM(Transactions[Deposit]) - SUM(Transactions[Withdrawal]), LASTDATE(Calendar))

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors