Soutenez Time.now : Rejoignez notre Plan Premium pour une expérience sans publicité ! Soutenez-nous : Passez Premium sans pub !

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.

Instructions étape par étape

  1. Create a calculated column or measure.
  2. Use WEEKNUM('Table'[DateColumn], 21): return type 21 selects ISO 8601 numbering.
  3. For a matching ISO year column, use the year of the week's Thursday: YEAR([DateColumn] + 4 - WEEKDAY([DateColumn], 2)).

Bon à savoir

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.