WEEKNUM

The WEEKNUM function returns the week number of the year to which the date passed as an argument belongs.

Syntax

WEEKNUM(
    date
    [, return_type]
)

Parameters
  • date: Date in datetime format.
  • return_type: Optional argument. Number (1 or 2) that determines the value to be returned by the function:
  1. (Default value) Weeks start on Sunday and the days of the week are numbered from 1 to 7.
  2. Weeks start on Monday and the days of the week are numbered from 1 to 7.
Returned value

The WEEKNUM function returns an integer.

Additional Information

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.

Examples

The year 2017 started on a Sunday:

January 2017

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:

Week number = WEEKNUM(DATE(2017, 1, 2))
WEEKNUM function. Example of use

Of course, this result matches the one we get if we specify the value 1 as the return_type argument:

Week number = WEEKNUM(DATE(2017, 1, 2), 1)
WEEKNUM function. Example of use

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:

Week number = WEEKNUM(DATE(2017, 1, 2), 2)
WEEKNUM function. Example of use
Scenarios
Category
Date and time
Submitted by admin on Fri, 01/04/2019 - 13:25