Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I have created a date table using DAX ...
Solved! Go to Solution.
@duncanwil
You can use the right function (WEEKNUM) to extract the week number than the FORMAT function. Use the following calendar table code. it should work for you.
Dates =
VAR StartYear = 2020
VAR EndYear = 2021
VAR DatesColumn =
CALENDAR(
DATE(StartYear , 1 , 1),
DATE(EndYear, 12 , 31)
)
RETURN
ADDCOLUMNS(
DatesColumn,
"Month No" , MONTH([Date]),
"Month Name" , FORMAT( [Date] , "Mmmm" ),
"Year" , YEAR([Date]),
"Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
"Month Year" , FORMAT( [Date] , "Mmm yyyy"),
"Quarter" , QUARTER([Date]),
"Qtr Name" , FORMAT( [Date] , "\QQ"),
"Week Day" , WEEKDAY([Date],2),
"Week" , FORMAT( [Date] , "Dddd" ),
"Week No" , WEEKNUM([Date],2),
"Week Num" , "WK - " & WEEKNUM([Date],2)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thank you both. I have to confess that I had read those pages/suggestions but my lack of DAX experience led me to assume FORMAT was OK.
So, I repgrammed to use WEEKNUM and so on and the tables are behaving as expected.
Duncan
Detailed reference
https://docs.microsoft.com/en-us/dax/format-function-dax
Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@duncanwil
You can use the right function (WEEKNUM) to extract the week number than the FORMAT function. Use the following calendar table code. it should work for you.
Dates =
VAR StartYear = 2020
VAR EndYear = 2021
VAR DatesColumn =
CALENDAR(
DATE(StartYear , 1 , 1),
DATE(EndYear, 12 , 31)
)
RETURN
ADDCOLUMNS(
DatesColumn,
"Month No" , MONTH([Date]),
"Month Name" , FORMAT( [Date] , "Mmmm" ),
"Year" , YEAR([Date]),
"Month Year No" , (YEAR([Date]) * 100) + MONTH([Date]),
"Month Year" , FORMAT( [Date] , "Mmm yyyy"),
"Quarter" , QUARTER([Date]),
"Qtr Name" , FORMAT( [Date] , "\QQ"),
"Week Day" , WEEKDAY([Date],2),
"Week" , FORMAT( [Date] , "Dddd" ),
"Week No" , WEEKNUM([Date],2),
"Week Num" , "WK - " & WEEKNUM([Date],2)
)
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
93 | |
85 | |
84 | |
73 | |
49 |
User | Count |
---|---|
142 | |
133 | |
110 | |
68 | |
55 |