If you don’t have a date table with a column that represents the day of the week name (Saturday, Sunday, Monday etc) or number (from zero to six, or from one to seven), and you just have a date field, which you want to quickly get the day name of the week, here is a quick trick for you.
Sample Table
The below DAX calculated table is a table with a list of dates in it;
calendar = CALENDAR(
DATE(2020,1,1)
,TODAY()
)
I have previously explained how you can use Calendar or CalendarAuto to create a table of dates in DAX, read more about that here.
Day of Week Name
Now, If you want to get the Day of Week Name from this date, which is Monday, Tuesday, Wednesday, etc. You can use the FORMAT function as below:
Day of Week Name = FORMAT('calendar'[Date],"dddd")
Three Characters
If you just want the three-character day of week name, you can use “ddd” in the format function as below;
3 characters =
FORMAT(
'calendar'[Date],
"ddd"
)
There are many other format strings which are helpful to get other date or time attributes, you can find them all here.
Day Number of Week
If you just want a number representing the day number of week, then you can use WeekDay function;
WeekDay = WEEKDAY('calendar'[Date])
The default setting is that the weekday starts on Sunday being 1, and then Saturday is 7. You can change it with the 2nd parameter of the Weekday function as below:
- Return type: 1, week begins on Sunday (1) and ends on Saturday (7). numbered 1 through 7.
- Return type: 2, week begins on Monday (1) and ends on Sunday (7).
- Return type: 3, week begins on Monday (0) and ends on Sunday (6).numbered 1 through 7.
Reference: https://docs.microsoft.com/en-us/dax/weekday-function-dax
weekday starting Monday 1 = WEEKDAY('calendar'[Date],2)
Date Table
It would be always, however, far better and more flexible if you have a full calendar or date dimension. I have shared the Power Query script to create one here.