Forum Discussion
ENDING BALANCE AS BEGINNING BALANCE NEXT DAY
- 1 year ago
Hi Anonymous , you want:
- Beginning Balance of each date = Ending Balance of the previous date
- Ending Balance = Beginning Balance + Total Receipt – Total Payment
Step 1 — Calculate Ending Balance
You can use this calculated column (if you already have the Beginning Balance):
Ending Balance =
[Beginning Balance] + [Total Receipt] - [Total Payment]
Step 2 — Calculate Beginning Balance dynamically
If you want to compute the Beginning Balance automatically from the previous day's Ending Balance, use this DAX:
Beginning Balance =
VAR CurrentDate = [Date]
VAR PrevDate =
CALCULATE(
MAX('Table'[Date]),
FILTER('Table', 'Table'[Date] < CurrentDate)
)
VAR PrevEnding =
CALCULATE(
MAX('Table'[Ending Balance]),
FILTER('Table', 'Table'[Date] = PrevDate)
)
RETURN
IF(
ISBLANK(PrevEnding),
[Beginning Balance], // Keep first day's balance as starting point
PrevEnding
)
Step 3 — Optional: Recalculate Ending Balance consistently
To make it fully dynamic (so you don’t need to manually set Beginning Balance each day), use this:
Ending Balance =
VAR CurrentDate = [Date]
VAR PrevDate =
CALCULATE(
MAX('Table'[Date]),
FILTER('Table', 'Table'[Date] < CurrentDate)
)
VAR PrevEnding =
CALCULATE(
MAX('Table'[Ending Balance]),
FILTER('Table', 'Table'[Date] = PrevDate)
)
VAR Beginning =
IF(
ISBLANK(PrevEnding),
[Beginning Balance],
PrevEnding
)
RETURN
Beginning + [Total Receipt] - [Total Payment]
Important Notes:
- Replace 'Table' with your actual table name.
- Make sure [Date] is a Date data type (not text).
- Sort your visuals by Date ascending.
If this post helped resolve your issue, please mark it as the accepted solution to make it easier for others to find.
Regards,
Khashayar Yazdani | Microsoft MCT
https://www.linkedin.com/in/khashayary/
Anonymous , Try using
Beginning Balance =
VAR PrevDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Date] < EARLIER('Table'[Date])
)
)
RETURN
IF(
ISBLANK(PrevDate),
'Table'[Beginning Balance], // For the first row, keep the original value
CALCULATE(
MAX('Table'[Ending Balance]),
FILTER('Table', 'Table'[Date] = PrevDate)
)
)
Not working. Sep 23 beginning balance is still using the beginning balance of Sep 22, 10,079,297,420.51.
It should be using 9,979,154,330.51 + 12,084,102 - 21410927 = 9,969,827,505.51. I'm getting wrong value in ending balance of Sep 23.
- bhanu_gautam1 year ago
Super User
Anonymous , Try using
dax
Beginning Balance Dynamic =
VAR PrevDate =
CALCULATE(
MAX('Table'[Date]),
FILTER(
'Table',
'Table'[Date] < EARLIER('Table'[Date])
)
)
RETURN
IF(
ISBLANK(PrevDate),
'Table'[Beginning Balance], // For the first row, keep the original value
CALCULATE(
MAX('Table'[Ending Balance]),
FILTER('Table', 'Table'[Date] = PrevDate)
)
)Create a calculated column for Ending Balance as:
dax
Ending Balance Dynamic =
[Beginning Balance Dynamic] + [Total Receipt] - [Total Payment]