CLOSINGBALANCEWEEK DAX Function (Time Intelligence) Context Transition
Evaluates the specified expression for the date corresponding to the end of the current week after applying specified filters.
Syntax
| Parameter | Attributes | Description |
|---|---|---|
|
Expression By Expression |
The expression to be evaluated. |
|
| Calendar |
The name of a calendar. |
|
| Filter | Optional |
A boolean (True/False) expression or a table expression that defines a filter. |
Return values
A scalar value that represents the expression evaluated at the last date of the week in the current context.
Notes
In order to use any time intelligence calculation, you need a well-formed date table. The Date table must satisfy the following requirements:
- All dates need to be present for the years required. The Date table must always start on January 1 and end on December 31, including all the days in this range. If the report only references fiscal years, then the date table must include all the dates from the first to the last day of a fiscal year. For example, if the fiscal year 2008 starts on July 1, 2007, then the Date table must include all the days from July 1, 2007 to June 30, 2008.
- There needs to be a column with a DateTime or Date data type containing unique values. This column is usually called Date. Even though the Date column is often used to define relationships with other tables, this is not required. Still, the Date column must contain unique values and should be referenced by the Mark as Date Table feature. In case the column also contains a time part, no time should be used – for example, the time should always be 12:00 am.
- The Date table must be marked as a date table in the model, in case the relationship between the Date table and any other table is not based on the Date.
Remarks
CLOSINGBALANCEWEEK works only with calendar-based time intelligence. The Calendar argument must be a calendar reference. A date column is not valid and returns an error.
The calendar must tag the Week category. If the calendar does not tag the Week category, CLOSINGBALANCEWEEK returns an error.
The syntax CLOSINGBALANCEWEEK ( <Expression>, <Calendar> [, <Filter>] ) corresponds to CALCULATE ( <Expression>, ENDOFWEEK ( <Calendar> ) [, <Filter>] ).
The week is the week that the calendar defines. If the filter context contains more than one week, for example a month, CLOSINGBALANCEWEEK uses the last date of the week that contains the last date in the filter context. This date can be after the end of the month. For example, in the ‘Weekly 445’ calendar of the sample model, weeks end on Saturday. For November 2008, CLOSINGBALANCEWEEK uses Saturday, December 6, 2008.
Examples
DEFINE
MEASURE Sales[Sales YTD] =
CALCULATE ( [Sales Amount], DATESYTD ( 'Weekly 445' ) )
MEASURE Sales[Sales OBW] =
OPENINGBALANCEWEEK ( [Sales YTD], 'Weekly 445' )
MEASURE Sales[Sales CBW] =
CLOSINGBALANCEWEEK ( [Sales YTD], 'Weekly 445' )
EVALUATE
CALCULATETABLE (
SUMMARIZECOLUMNS (
'Date'[445 Year Week Number],
'Date'[445 Week Start],
'Date'[445 Week End],
"Sales", [Sales Amount],
"Sales YTD", [Sales YTD],
"Sales OBW", [Sales OBW],
"Sales CBW", [Sales CBW]
),
'Date'[445 Year Week Number] >= 200849,
'Date'[445 Year Week Number] <= 200903
)
ORDER BY 'Date'[445 Year Week Number]
| 445 Year Week Number | 445 Week Start | 445 Week End | Sales | Sales YTD | Sales OBW | Sales CBW |
|---|---|---|---|---|---|---|
| 200849 | 2008-11-30 | 2008-12-06 | 145,259.35 | 9,194,742.58 | 9,049,483.23 | 9,194,742.58 |
| 200850 | 2008-12-07 | 2008-12-13 | 275,751.94 | 9,470,494.52 | 9,194,742.58 | 9,470,494.52 |
| 200851 | 2008-12-14 | 2008-12-20 | 152,052.00 | 9,622,546.52 | 9,470,494.52 | 9,622,546.52 |
| 200852 | 2008-12-21 | 2008-12-27 | 165,554.93 | 9,788,101.45 | 9,622,546.52 | 9,788,101.45 |
| 200853 | 2008-12-28 | 2009-01-03 | 270,201.87 | 10,058,303.31 | 9,788,101.45 | 10,058,303.31 |
| 200901 | 2009-01-04 | 2009-01-10 | 130,058.72 | 130,058.72 | 10,058,303.31 | 130,058.72 |
| 200902 | 2009-01-11 | 2009-01-17 | 90,908.45 | 220,967.17 | 130,058.72 | 220,967.17 |
| 200903 | 2009-01-18 | 2009-01-24 | 213,019.41 | 433,986.58 | 220,967.17 | 433,986.58 |
Related functions
Other related functions are:
Last update: Nov 1, 2026 » Contribute » Show contributors
Contributors: Alberto Ferrari, Marco Russo
Microsoft documentation: https://learn.microsoft.com/en-us/dax/closingbalanceweek-function-dax