DAX Date & Time - WEEKDAY function


Advertisements

Description

Returns a number identifying the day of the week of a date.

Syntax

WEEKDAY (<date>, [<return_type>]) 

Parameters

Sr.No. Parameter & Description
1

date

A date in datetime format.

2

return_type

Optional.

A number that determines the return value −

1 - Week begins on Sunday (1) and ends on Saturday (7), numbered 1 through 7.

2 - Week begins on Monday (1) and ends on Sunday (7), numbered 1 through 7.

3 - Week begins on Monday (0) and ends on Sunday (6), numbered 0 through 6.

If omitted, default is 1.

Return Value

An integer from 0 to 7, based on the return type.

Remarks

The first parameter to the WEEKDAY function is the date of the day. DAX handles the date values in datetime format.

You can specify the date as one of the following −

  • Output of another date function.
  • An expression that returns a date value.
  • A date in a datetime format.
  • A date as text representation in one of the accepted string formats for dates.

DAX WEEKDAY function uses the locale and date/time settings of the client computer to understand the text value in order to perform the conversion. For example,

  • If the current date/time settings represent dates in the format of Month/Day/Year, then the string "1/8/2016" is understood as a datetime value equivalent to 8th January, 2016

  • If the current date/time settings represent dates in the format of Day/Month/Year, the same string would be understood as a datetime value equivalent to 1st August, 2016.

Example

= WEEKDAY ("1-5-2016") returns 3. 
= WEEKDAY (TODAY (),2) returns 5. (If today is Friday). 
dax_functions_date_time.htm

Useful Video Courses


Video

Mastering DAX and Data Models in Power BI Desktop

53 Lectures 5.5 hours

Abhay Gadiya

Video

Mastering DAX Studio

Featured

24 Lectures 2 hours

Randy Minder

Video

DAX / Power BI - Customer and Sales Analysis Deep Dive

26 Lectures 4.5 hours

Randy Minder

Advertisements