<!-- https://learnsql.cpetoday.com/functions/dax/closingbalancemonth -->
# CLOSINGBALANCEMONTH

Language: DAX
Category: Time intelligence: balances
Syntax: CLOSINGBALANCEMONTH(<expression>, <dates> [, <filter>])
Summary: Evaluates an expression on the last date of the month in the filter context, for balances that do not add up over time.
Returns: A value (a scalar).
Level: Intermediate
Related: LASTDATE, LASTNONBLANK, OPENINGBALANCEMONTH, CLOSINGBALANCEQUARTER, CALCULATE

## What it does
CLOSINGBALANCEMONTH returns the balance at the end of the month, not the total of the month's rows. Inventory, bank balances, receivables and headcount are balances: a stock count on March 31 is the stock on hand, not the sum of the stock counts taken each day. This function reads the value on the last day of the month, so the figure is right for the month-end close. It is the standard tool for semi-additive measures.

## Syntax and arguments
- expression: the measure or column that holds the balance, such as SUM('Inventory'[Units]). Required.
- dates: the date column of the Calendar table. Required.
- filter: an optional filter, such as an account or a location. Optional.

## Example
A manufacturer has a daily inventory snapshot with one row for each product on each day. The controller wants the units on hand at each month end.

```dax
Closing Units = CLOSINGBALANCEMONTH(SUM('Inventory'[Units]), 'Calendar'[Date])
```

In the March 2027 row, the measure returns the units on hand on March 31, 2027, for the products in that filter. Adding up the months would give a meaningless number, but the closing balance gives the count that appears on the balance sheet.

## Example: a second, different use
The month-end cash balance for the operating bank account, from a daily balance table. The filter picks the account, and the function reads the balance on the last day.

```dax
Operating Cash Month End =
CLOSINGBALANCEMONTH(
    SUM('Bank_Balances'[Balance]),
    'Calendar'[Date],
    'Bank_Balances'[Account] = "Operating"
)
```

## Things to watch
- Use it only on a balance table, with one row per date for each item. Applied to a list of transactions, it gives the balance on the last day with a row, which is not the same as a running balance.
- The function reads the value on the last date of the month. If the balance table has no row on that day, the result is blank. Check coverage before you publish, or use a last-date-with-data pattern (see LASTNONBLANK).
- Use the Calendar's date column, and make sure the Calendar includes every month-end date.
- It is calculated per month in the filter context. For a quarter or year total, use the quarter or year version.

## In business terms
CLOSINGBALANCEMONTH supports the month-end balance sheet for inventory, cash, receivables and deferred revenue. Controllers use it for the reconciliation of the bank and the stock count at close, and for the trend of balances across months. Getting balances right is the core of a semi-additive measure, and it is one of the most common errors in finance dashboards when the wrong sum is used.
