Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi all,
I wanted to calculate a column in a tabel for week start date based on a year week number integer
as below..
YearWeek Start Of the Week (new calculated column based on YearWeek column)
20211 1/1/2021
20212 4/1/2021
20213 11/1/2021
....
....
202141 6/9/2021
202142 13/9/2021
is there any way I can do this. thanks for the help
@Anonymous
Solved! Go to Solution.
Simple enough with PQ,
let
Source = List.TransformMany({2021,2022}, each {1..Date.WeekOfYear(#date(_,12,31), Day.Monday)}, (x,y) => {Text.From(x)&"-"&Number.ToText(y,"00"), List.Max({#date(x,1,1), Date.StartOfWeek(#date(x,1,1)+Duration.From((y-1)*7),Day.Monday)})}),
#"Start of Week" = Table.FromRows(Source, {"yyyyww", "Start of Week"})
in
#"Start of Week"
| 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! |
Simple enough with PQ,
let
Source = List.TransformMany({2021,2022}, each {1..Date.WeekOfYear(#date(_,12,31), Day.Monday)}, (x,y) => {Text.From(x)&"-"&Number.ToText(y,"00"), List.Max({#date(x,1,1), Date.StartOfWeek(#date(x,1,1)+Duration.From((y-1)*7),Day.Monday)})}),
#"Start of Week" = Table.FromRows(Source, {"yyyyww", "Start of Week"})
in
#"Start of Week"
| 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! |
HI @amalrio
It would be better to add a calendar table to your model and use that.
BTW, Try this code:
Column =
Var _WN = FORMAT(right([YearWeek],LEN([YearWeek])-4),"####")
Var _MinYear = CALCULATE(left(min([YearWeek]),4),all('Table'))
Var _MaxYear = CALCULATE(left(Max([YearWeek]),4),all('Table'))
Var _Year = FORMAT(left([YearWeek],4),"####")
Var _DateT = filter(ADDCOLUMNS(calendar(Date(_MinYear,1,1),date(_MaxYear,12,31)),"Year",YEAR([Date]),"WeekN",WEEKNUM([Date]),"Day",format([Date],"ddd")),[Day]<>"Sat"&&[Day]<>"Sun")
Var _FirstDateWeek =ADDCOLUMNS(GROUPBY(_DateT,[WeekN],[Year],"Date",minx(CURRENTGROUP(),[Date])),"YW",CONCATENATE([Year],[WeekN]))
return
MAXX(filter(_FirstDateWeek,VALUE([YW])=[YearWeek]),[Date])
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 103 | |
| 80 | |
| 59 | |
| 51 | |
| 46 |