Daily DAX : Day 386 WEEKNUM
Power BI DAX: WEEKNUM Function
Syntax
WEEKNUM(<date> [, <return_type>])
Parameters
| Parameter | Description |
|---|---|
<date> |
A date in datetime format or a column containing dates. |
<return_type> (optional) |
A number that determines the week numbering system: 1 or omitted: Week begins on Sunday (ISO week 1 contains Jan 4). 2: Week begins on Monday (ISO 8601 standard). 21: Week begins on Sunday (week 1 is the first week with 4+ days in the new year). |
Return Value
An integer representing the week number of the year for the given date.
Use Cases
- Weekly Sales Reporting: Group sales data by week for trend analysis.
- Time Intelligence: Compare performance across weeks (e.g., Week 5 of 2024 vs. Week 5 of 2025).
- Fiscal Calendar Alignment: Use
return_type = 2for ISO 8601 compliance in international reporting. - Dashboard Filters: Allow users to filter visuals by week number.
Examples
1. Basic Week Number (Sunday-based)
Week Number = WEEKNUM('Date'[Date])
Result: For Jan 1, 2025 (Wednesday) → Returns 1 (week starts on Sunday).
2. ISO Week Number (Monday-based)
ISO Week = WEEKNUM('Date'[Date], 2)
Result: For Jan 1, 2025 → Returns 1 (ISO week starts Monday; Jan 1–2 are in week 1 of 2025).
3. Calculated Column in a Date Table
Week Number ISO = WEEKNUM('Calendar'[Date], 2)
Used to create a proper fiscal or reporting week dimension.
Note: Always specify
return_type = 2 for consistent international reporting (ISO 8601). Avoid default 1 unless your organization uses Sunday-start weeks.
Common Pitfalls
- Using default
return_type = 1may cause misalignment with ISO standards. - Week 1 may include days from the previous year (especially with
return_type = 21).
Comments
Post a Comment