Forum Discussion
Assign Week Number to a Single Month Across Multiple Years
- 10 months ago
Hi , tl1234
My recommended approache is instead of relying on month and week columns from your fact tables, create a Date Dimension with:
- Continuous dates.
- Columns for Year, Month, Month Name, Week Number, and optionally Year-Week (e.g., 2025-W01).
- Mark this table as Date Table in Power BI.Then:
- Relate your combined table to this Date Table using a proper date key.
- Use the hierarchy from the Date Table in visuals (Year → Month → Week).
This ensures consistent sorting and avoids the “ugly” misalignment.You can generate this Date Table in Power Query easily:
let StartDate = #date(2022, 1, 1), EndDate = #date(2025, 12, 31), Dates = List.Dates(StartDate, Duration.Days(EndDate - StartDate)+1, #duration(1,0,0,0)), Table = Table.FromList(Dates, Splitter.SplitByNothing(), {"Date"}), AddColumns = Table.TransformColumns(Table, {{"Date", type date}}), AddYear = Table.AddColumn(AddColumns, "Year", each Date.Year([Date])), AddMonth = Table.AddColumn(AddYear, "Month", each Date.Month([Date])), AddMonthName = Table.AddColumn(AddMonth, "Month Name", each Date.MonthName([Date])), AddWeek = Table.AddColumn(AddMonthName, "Week Number", each Date.WeekOfYear([Date])) inIf this response was helpful in any way, I’d gladly accept a 👍much like the joy of seeing a DAX measure work first time without needing another FILTER.
Please mark it as the correct solution. It helps other community members find their way faster (and saves them from another endless loop 🌀.
Hi tl1234,
Thank you for reaching out to Microsoft Fabric Community.
Thank you anilelmastasi and Zanqueta for the prompt response.
As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the user's for the issue worked? or let us know if you need any further assistance.
Thanks and regards,
Anjan Kumar Chippa