WEEKNUM DAX Function (Date and Time)

Returns the week number in the year.

Syntax

WEEKNUM ( <Date> [, <ReturnType>] )
Parameter Attributes Description
Date

A date in datetime format.

ReturnType Optional

A number that determines the return value: for example, use 1 when week begins on Sunday, or use 2 when week begins on Monday, or use 21 for ISO week numbers. More details in Remarks section.

Return values

Scalar A single integer value.

The week number for the given date.

Remarks

If the argument is a string, it is translated into a datetime value using the same rules applied by the DATEVALUE function.

There are two systems used for this function:

  • System 1 The week containing January 1 is the first week of the year, and is numbered week 1.
  • System 2 The week containing the first Thursday of the year is the first week of the year, and is numbered as week 1. This system is the methodology specified in ISO 8601, which is commonly known as the European week numbering system.
Return_type Week begins on System
1 or omitted Sunday 1
2 Monday 1
11 Monday 1
12 Tuesday 1
13 Wednesday 1
14 Thursday 1
15 Friday 1
16 Saturday 1
17 Sunday 1
21 Monday 2
» 2 related functions

Examples

--
--    WEEKNUM returns the week number following different standards
--
EVALUATE 
ADDCOLUMNS ( 
    TOPN ( 10, VALUES ( 'Date'[Date] ), 'Date'[Date], ASC ),
    "Day of week", FORMAT ( 'Date'[Date], "dddd" ),
    "WEEKNUM",    WEEKNUM ( 'Date'[Date] ) ,    -- Same as 1, week start on Sun
    "WEEKNUM  2", WEEKNUM ( 'Date'[Date],  2 ), -- Week start on Mon
    "WEEKNUM 11", WEEKNUM ( 'Date'[Date], 11 ), -- 11 to 17: 1st DOW Mon 
    "WEEKNUM 12", WEEKNUM ( 'Date'[Date], 12 ), -- 11 to 17: 1st DOW Tue
    "WEEKNUM 13", WEEKNUM ( 'Date'[Date], 13 ), -- 11 to 17: 1st DOW Wed
    "WEEKNUM 21", WEEKNUM ( 'Date'[Date], 21 )  -- ISO 8601 Week 
                                                -- (1st thursday of the year)
)
ORDER BY 'Date'[Date]
Date Day of week WEEKNUM WEEKNUM 2 WEEKNUM 11 WEEKNUM 12 WEEKNUM 13 WEEKNUM 21
2005-01-01 Saturday 1 1 1 1 1 53
2005-01-02 Sunday 2 1 1 1 1 53
2005-01-03 Monday 2 2 2 1 1 1
2005-01-04 Tuesday 2 2 2 2 1 1
2005-01-05 Wednesday 2 2 2 2 2 1
2005-01-06 Thursday 2 2 2 2 2 1
2005-01-07 Friday 2 2 2 2 2 1
2005-01-08 Saturday 2 2 2 2 2 1
2005-01-09 Sunday 3 2 2 2 2 1
2005-01-10 Monday 3 3 3 2 2 2

Related functions

Other related functions are:

Last update: Nov 14, 2024   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo

Microsoft documentation: https://docs.microsoft.com/en-us/dax/weeknum-function-dax

2018-2024 © SQLBI. All rights are reserved. Information coming from Microsoft documentation is property of Microsoft Corp. » Contact us   » Privacy Policy & Cookies

Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Volatile

A volatile function may return a different result every time you call it, even if you provide the same arguments. Click to read more.

Deprecated

This parameter is deprecated and its use is not recommended.

DirectQuery compatibility

Limitations are placed on DAX expressions allowed in measures and calculated columns.
The state below shows the DirectQuery compatibility of the DAX function.

Contribute

Want to improve the content of WEEKNUM? Did you find any issue?
Please, report it us! All submissions will be evaluated for possible updates of the content.


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.