DAX code
Opening Balance =
CALCULATE([Total Sales], DATESBETWEEN('Date'[Date], BLANK(), STARTOFMONTH(MIN('Date'[Date])) - 1))
Closing Balance =
CALCULATE([Total Sales], DATESBETWEEN('Date'[Date], BLANK(), MAX('Date'[Date])))
Calculates the account or inventory balance at the start and end of the current filter period.
Type your table and column names once. Every measure below updates.
Opening Balance =
CALCULATE([Total Sales], DATESBETWEEN('Date'[Date], BLANK(), STARTOFMONTH(MIN('Date'[Date])) - 1))
Closing Balance =
CALCULATE([Total Sales], DATESBETWEEN('Date'[Date], BLANK(), MAX('Date'[Date])))
This treats the balance as a cumulative sum of transactions; use LASTNONBLANK instead if the fact table already stores a running balance snapshot.
Browse all 175 measures in the Power BI DAX Measures Library, or search the library for something similar to Opening Balance and Closing Balance.