Get the Day of the Week Name and Number in Power BI Using DAX

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")
Get the Day of Week Name in DAX

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.

Video

Reza Rad on FacebookReza Rad on LinkedinReza Rad on TwitterReza Rad on Youtube
Reza Rad
Trainer, Consultant, Mentor
Reza Rad is a Microsoft Regional Director, an Author, Trainer, Speaker and Consultant. He has a BSc in Computer engineering; he has more than 20 years’ experience in data analysis, BI, databases, programming, and development mostly on Microsoft technologies. He is a Microsoft Data Platform MVP for 12 continuous years (from 2011 till now) for his dedication in Microsoft BI. Reza is an active blogger and co-founder of RADACAD. Reza is also co-founder and co-organizer of Difinity conference in New Zealand, Power BI Summit, and Data Insight Summit.
Reza is author of more than 14 books on Microsoft Business Intelligence, most of these books are published under Power BI category. Among these are books such as Power BI DAX Simplified, Pro Power BI Architecture, Power BI from Rookie to Rock Star, Power Query books series, Row-Level Security in Power BI and etc.
He is an International Speaker in Microsoft Ignite, Microsoft Business Applications Summit, Data Insight Summit, PASS Summit, SQL Saturday and SQL user groups. And He is a Microsoft Certified Trainer.
Reza’s passion is to help you find the best data solution, he is Data enthusiast.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.

Leave a Reply