Forum Discussion

dedelman_clng's avatar
dedelman_clng
Community Champion
5 years ago
Solved

Date.WeekOfMonth to start on Monday?

Is there a switch for the PowerQuery/M function Date.WeekOfMonth that will tell it that a week is Monday-Sunday instead of Sunday-Saturday?

 

I know I can do it with an IF statement based on the day of the week - just wondering if the function has the capability.

 

Thanks

David

  • Yes, just change the start day parameter:

     

    Date.WeekOfMonth(dateTime as any, optional firstDayOfWeek as nullable number) as nullable number  

     

    Use Day.Monday for the FirstDayOfWeek parameter.

     

    Many of the date functions, especially the Week functions, have this. They assume Day.Sunday I think, but you can easily change that to any day of the week.

3 Replies

  • edhans's avatar
    edhans
    Community Champion

    Yes, just change the start day parameter:

     

    Date.WeekOfMonth(dateTime as any, optional firstDayOfWeek as nullable number) as nullable number  

     

    Use Day.Monday for the FirstDayOfWeek parameter.

     

    Many of the date functions, especially the Week functions, have this. They assume Day.Sunday I think, but you can easily change that to any day of the week.

    • edhans's avatar
      edhans
      Community Champion

      I've often seen parameters fail to show up until you hit the comma before that parameter, and if you don't know to look for it with a comma....

      I wouldn't rely on Intellisense in PQ to help in the same way it does in DAX or in Excel. It isn't quite at that level.