Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NLEIGH
New Member

How to sort by day of the week

Hi, 

 

Please can someone let me know how to sort a column in a table by week day (ie Mon, Tue, Wed etc), I have tried to do this via the sort by column button, however I dont seem to get the same options as shown sources.

 

Please see below visual of the table.  Any help would be much appreciated.

 

NLEIGH_0-1698766741403.png

 

 

4 REPLIES 4
NLEIGH
New Member

Hi,

 

Is this what you meant ?  the data used is from the "2023 Raw Data" file and i'm using the "Day" data.

 

NLEIGH_0-1699363948529.png

 

JorgePinho
Solution Sage
Solution Sage

Hello @NLEIGH !

In Power BI, follow these steps:

  1. Click on the "Modeling" tab in the Power BI Desktop application.

  2. New Column: In the "Modeling" tab, click on the "New Column" option. This will allow you to create a custom column that you can use for sorting. In the formula bar that appears, enter this DAX formula that assigns a numerical value to each of the week days:WeekdayOrder = SWITCH([Weekday], "Mon", 1, "Tue", 2, "Wed", 3, "Thu", 4, "Fri", 5, "Sat", 6, "Sun", 7)

    In this formula, "Weekday" should be replaced with the name of your column containing the week days. 

  3. Now select the original column (the one with Mon, Tue...) and then on the column tools use the Sort By Column and choose the new costum column we just created.

Remember to adjust the DAX formula if your week day column contains different values or labels for week days.

Hi Jorge, Many thanks for taking the time to reply.  I have tried to follow the steps (i'm still new to Power Bi), however i'm getting this error message when I try to sort by the new column I've created.

RJLEIGH_0-1698926899357.png

I've also attached below a screenshot of the new column measure just in case that helps

 

RJLEIGH_1-1698926962437.png

Do you have any idea what i've done wrong 

 

Many thanks

 

Can you show your data model please?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.