Date.StartOfWeek

Date

Returns the first day of the week containing the given date.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

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

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value.
firstDayOfWeeknumberNoA Day.* constant specifying the first day of the week. Defaults to Day.Sunday (0). Use Day.Monday (1) for ISO weeks.

Return Value

anyA date, datetime, or datetimezone value representing the first day of the week.

Remarks

Date.StartOfWeek returns the first day of the calendar week containing the input value. By default, weeks start on Sunday (Day.Sunday = 0). Pass Day.Monday (1) for ISO 8601-style Monday-to-Sunday weeks. The return type matches the input type: a plain date input returns a date; a datetime or datetimezone input returns the same type with the time component set to midnight of the week-start day.

Always use the Day.* enum constants (e.g., Day.Monday, Day.Sunday) rather than integer literals for the firstDayOfWeek parameter. This makes code self-documenting and avoids confusion.

Pair Date.StartOfWeek with Date.EndOfWeek using the same firstDayOfWeek value to build consistent weekly range filters. Date.StartOfWeek is also used as a grouping key for weekly aggregations — group by Date.StartOfWeek([OrderDate], Day.Monday) to bucket all orders into their ISO week.

Examples

Example 1: Add the week start date to each order

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Sales, 5),
        {"OrderID", "OrderDate"}
    ),
    "WeekStart", each Date.StartOfWeek([OrderDate], Day.Sunday), type date
)
Result
OrderID
OrderDate
WeekStart
111/15/20241/14/2024
221/18/20241/14/2024
332/1/20241/28/2024
442/10/20242/4/2024
553/5/20243/3/2024

Example 2: Start of ISO week (Monday start)

#table(
    type table [Date = date, ISOWeekStart = date],
    {{#date(2024, 3, 13), Date.StartOfWeek(#date(2024, 3, 13), Day.Monday)}}
)
Result
Date
ISOWeekStart
13/13/20243/11/2024

Example 3: Group sales by week start for weekly aggregation

Table.AddColumn(
    Table.SelectColumns(Sales, {"OrderID", "OrderDate", "UnitPrice", "Quantity"}),
    "WeekStarting",
    each Date.StartOfWeek([OrderDate], Day.Monday),
    type date
)
Result
OrderID
OrderDate
UnitPrice
Quantity
WeekStarting
111/15/20242541/15/2024
221/18/20245021/15/2024
332/1/202415101/29/2024
442/10/20247512/5/2024
553/5/20242563/4/2024
663/12/202412013/11/2024
774/1/20245034/1/2024
884/15/20241584/15/2024

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks