Forum Discussion

Mramono's avatar
Mramono
Icon for Helper III rankHelper III
1 year ago
Solved

Adding Weeknum on the Calendar Table provided by Avi Singh

Friends Avi Singh published a very nice Calendar table and i've been using it. However the column "WeekSequenceNum" starts counting from the first day in the table, but i also wanted to add a "Weeknu...
  • NimaiAhluwalia's avatar
    1 year ago

    Hello Mramono 

     

    Your issue:
    Right now, WeekSequenceNum starts counting from April (your Calendar start), so 1st April is Week 1. But you want 1st April to be Week 14 (since weeks should start from January).

     

    In your M Query, right at the end step, add this line:

     

    #"Inserted WeekNum_StartingMonday" = Table.AddColumn(#"Changed Type1", "WeekNum", each Date.WeekOfYear([Date], Day.Monday), Int64.Type)
    in
    #"Inserted WeekNum_StartingMonday"

     

     

    This new WeekNum column will:

    • Always start counting weeks from 1st January,

    • Use Monday as the first day of the week,

    • And correctly give you 1st April 2025 = Week 14.

     

    I believe there is also a Week of Year column in your table, which is working fine and starts from 14. If you want, you can use that column also, if not you can use the above solution

  • Ahmedx's avatar
    1 year ago

    try this

    Date.WeekOfYear([Date],1)