OpenBI Docs Buy

WEEKDAY

The day of the week of a date, 1 to 7 from Sunday by default; other types start the week on another day, or count Monday as 0.

Group: Date and time. Compatible with DAX.

Syntax

WEEKDAY ( <date> [, <return_type>] )
ParameterTypeDescription
dateDateThe date whose day of the week is wanted.
return_typeWhole number
optional
How the days are numbered: 1 (when left out) Sunday 1 to Saturday 7; 2 Monday 1 to Sunday 7; 3 Monday 0 to Sunday 6; 11 to 17 a week that starts on Monday (11), Tuesday (12) and so on to Sunday (17), numbered 1 to 7.

Returns

Whole number. The day's number in its week.

Remarks

  • A blank date gives BLANK. A number is a date number: day 0, 30 December 1899, was a Saturday.
  • Any other numbering, a blank one included, is an error.
  • With type 2, WEEKDAY ( date, 2 ) > 5 picks out Saturdays and Sundays.

Examples

A Sunday and a Monday, three ways

17 March 2024 was a Sunday.

EVALUATE
VAR Sunday = DATE ( 2024, 3, 17 )
VAR Monday = DATE ( 2024, 3, 18 )
RETURN
    ROW (
        "Sunday, 1", WEEKDAY ( Sunday ), "Sunday, 2", WEEKDAY ( Sunday, 2 ), "Sunday, 3", WEEKDAY ( Sunday, 3 ),
        "Monday, 1", WEEKDAY ( Monday ), "Monday, 2", WEEKDAY ( Monday, 2 ), "Monday, 3", WEEKDAY ( Monday, 3 )
    )
Sunday, 1Sunday, 2Sunday, 3Monday, 1Monday, 2Monday, 3
176210

Weeks that start on other days

EVALUATE
VAR Monday = DATE ( 2024, 3, 18 )
RETURN
    ROW ( "From Monday", WEEKDAY ( Monday, 11 ), "From Wednesday", WEEKDAY ( Monday, 13 ),
          "From Sunday", WEEKDAY ( Monday, 17 ) )
From MondayFrom WednesdayFrom Sunday
162

Price days by day of the week

Prices are quoted on working days only: no 6 or 7.

EVALUATE
GROUPBY (
    ADDCOLUMNS ( VALUES ( Prices[Date] ), "Weekday", WEEKDAY ( Prices[Date], 2 ) ),
    [Weekday],
    "Days", COUNTX ( CURRENTGROUP (), 1 )
)
ORDER BY [Weekday]
WeekdayDays
1154
2154
3155
4154
5154

WEEKNUM, NETWORKDAYS, DAY, FORMAT.

Last updated · OpenBI Studio 0.3.74