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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube

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;

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:

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;

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;

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

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

FacebooktwitterredditpinterestlinkedintumblrmailFacebooktwitterredditpinterestlinkedintumblrmail
FacebooktwitterlinkedinrssyoutubeFacebooktwitterlinkedinrssyoutube
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 nine 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.
His articles on different aspects of technologies, especially on MS BI, can be found on his blog: https://radacad.com/blog.
He wrote some books on MS SQL BI and also is writing some others, He was also an active member on online technical forums such as MSDN and Experts-Exchange, and was a moderator of MSDN SQL Server forums, and is an MCP, MCSE, and MCITP of BI. He is the leader of the New Zealand Business Intelligence users group. He is also the author of very popular book Power BI from Rookie to Rock Star, which is free with more than 1700 pages of content and the Power BI Pro Architecture published by Apress.
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.

Leave a Reply