Power BI Date Table code with the week# in format YYWW

Hello

For all my power BI models I use the date table from the enterprise DNA , but I ’ missing a field for the weeknummer in the format “YYWW” example 2201 for week 1 ( week starts at monday )

Power BI Date Table code.txt (2.8 KB)

Thanks in advance
Roger

Hi @Roger,

Give this a go:

Table.AddColumn( 
    EnterPreviousStepNameHere, "YYWW", each 
    [ShortYear] & Text.PadStart( Text.From([Week Number]), 2, "0"),
    type text 
)

Also you need to add 1 day to the DayCount parameter with this version, as illustrated below.
DayCount = Duration.Days(Duration.From(EndDate - StartDate)) +1

Final note, if you need a ISO-8601 date table, I suggest you make the switch to this one:

I hope his is helpful.

2 Likes

Hi @Roger, did the response provided by @Melissa help you solve your query? If not, how far did you get and what kind of help you need further? If yes, kindly mark as solution the answer that solved your query. Thanks!