Forum Discussion

speedramps's avatar
speedramps
Super User
4 years ago
Solved

Parameter for Date.StartOfWeek([Date],Day.fieldname)

In Power Query the following command will return the Monday start of week for the Date

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

 

and this command will return the Sunday start of week for the Date

Date.StartOfWeek([Date],Day.Sunday)

 

How can I parameterise this please?

 

This kind of syntax is not allowed

 

Weekcommences = “Monday”

Date.StartOfWeek([Date],Day. Weekcommences)

 

Power Query solutions only pease. I don't want to use DAX for this problem.

 

Many thanks if you can help.

  •  

    Use 0/1/2..6 as the second parameter,

    = Date.StartOfWeek(Date.From(DateTime.LocalNow()), 1)

     

1 Reply

  • CNENFRNL's avatar
    CNENFRNL
    Community Champion

     

    Use 0/1/2..6 as the second parameter,

    = Date.StartOfWeek(Date.From(DateTime.LocalNow()), 1)