The WEEKNUM function returns the week number of the year to which the date passed as an argument belongs.
WEEKNUM(
date
[, return_type]
)
- date: Date in datetime format.
- return_type: Optional argument. Number (1 or 2) that determines the value to be returned by the function:
- (Default value) Weeks start on Sunday and the days of the week are numbered from 1 to 7.
- Weeks start on Monday and the days of the week are numbered from 1 to 7.
The WEEKNUM function returns an integer.
If the date argument is not in datetime format, DAX will convert it to this format to perform the calculations.
By default, the first day of the year corresponds to the first week of the year. This differs from the ISO 8601 standard according to which the first week of the year is the first one containing 4 or more days.
The year 2017 started on a Sunday:
This means that the WEEKNUM function, by default, considers that the first week started on day 1 (Sunday) and went until day 7. That is, Monday, January 2, belonged to week 1:
Of course, this result matches the one we get if we specify the value 1 as the return_type argument:
On the contrary, if we specified the value 2 as the return_type argument, weeks would start on Monday, which would mean that the first week of the year would start and end on Sunday, January 1, and the second week would start on Monday, January 2: