Date.StartOfWeek Function in Power Query
The Date.StartOfWeek function returns the start of the week for a given date, based on a specified first day of the week.
Syntax
Date.StartOfWeek(dateTime as any, optional firstDayOfWeek as nullable number) as any
The function has the following parameters:
- dateTime: The date or datetime to evaluate.
- firstDayOfWeek: It is an optional parameter. A number from 0 (Sunday) to 6 (Saturday). Default is 1 (Monday).
Day Number Reference
- Sunday: 0
- Monday: 1
- Tuesday: 2
- Wednesday: 3
- Thursday: 4
- Friday: 5
- Saturday: 6
Returns A date value representing the start of the week for the specified dateTime.
Example:
Power Query M
let Source = Date.StartOfWeek(#date(2025, 4, 5), 1) in Source
The output of the above code is 31-03-2025.
Key Benefits
- Helps in grouping or filtering data by week.
- Use with Date.EndOfWeek for defining full week ranges.
- Works seamlessly with time intelligence in reporting.