Forum Discussion

IF's avatar
IF
Post Prodigy
2 years ago
Solved

Power query week number

Hi, In power query i have a date table. I want to exract the number of the week. However it starts the week on Sunday. How can i change it and start the week from Monday. For example, I want to see ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    You can add the optional week start parameter to your Date.WeekOfYear, like

     

    Date.WeekOfYear([Date], Day.Monday)

     

    --Nate

  • dufoq3's avatar
    2 years ago

    Hi IF,

     

    let
        Source = #table(type table[Date=date], {{#date(2024,1,7)}}),
        #"Inserted Week of Year" = Table.AddColumn(Source, "Week of Year", each Date.WeekOfYear([Date], Day.Monday), Int64.Type),
        #"Inserted Day of Week" = Table.AddColumn(#"Inserted Week of Year", "Day of Week", each Date.DayOfWeek([Date], Day.Monday) +1, Int64.Type)
    in
        #"Inserted Day of Week"