Week numbers in Power BI (DAX)
To get the current ISO 8601 week number in Power BI (DAX), use the following code snippet:
WEEKNUM('Table'[DateColumn], 21) -- 21 specifies ISO 8601
* Ensure your system or application regional settings are set to follow ISO 8601 standards (weeks start on Monday) if the output varies.
Step-by-Step Instructions
- Create a calculated column or measure.
- Use WEEKNUM('Table'[DateColumn], 21): return type 21 selects ISO 8601 numbering.
- For a matching ISO year column, use the year of the week's Thursday: YEAR([DateColumn] + 4 - WEEKDAY([DateColumn], 2)).
Good to Know
WEEKNUM's default return type (1) is the US system. DAX has no ISOYEAR function, hence the Thursday trick; without it, weekly charts double-count the week that straddles New Year.