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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
OlegV
Helper II
Helper II

Sort Week Day Names by Date

Hello,

I need to create a line chart, to show a price change during a week (from Friday to Thursday).

OlegV_0-1631963307803.png

 

But I am not able to sort WeekDay names BY DATE. The result I get is the following:

OlegV_2-1631962407179.png

What I have done so far:

1) created a column WeeDayName using a formular WeekDayName = FORMAT('Futures'[Дата],"ddd").
2) plotted a WeeDayName on an x-axis and price on a y-axis
3) used necessary dates as a page filter

 

Please help me! Thank you.

1 ACCEPTED SOLUTION
moizsherwani
Continued Contributor
Continued Contributor

I think I found a bug in PowerBI, if you intitially setup the sort of WEEKDAYNAME to be by WEEKDAYNUM = WEEKDAY([date]) and then change the formula of WEEKDAYNUM = DATEVALUE([date]) it continue to sort correctly on the graph. If you try to sort it by column again then it gives this error. That said, this may not be the best solution so please find another solution below

 

Put the date on the X Axis and change the format of date to be 'ddd'. Make sure the X axis is changed from Continuous to Categorical. Also if you need to keep the oringinal date column as well you can simply make the WeekDayNum a duplicate of the Date column using = [Date]. Let me know if this works

 

moizsherwani_0-1631966286126.png

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

View solution in original post

6 REPLIES 6
moizsherwani
Continued Contributor
Continued Contributor

You can create a column called "WeekDayNum" using the formula below and Sort "WeekDayName" by WeekDayNum"

 

 

WeekDayNum = WEEKDAY('Sample'[Date])

 

 

 

moizsherwani_0-1631963815179.png

 

moizsherwani_0-1631964051306.png

 

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

Thank you for a reply, but I need to sort WeekDay names BY DATE, not by Weekday number.

moizsherwani
Continued Contributor
Continued Contributor

Instead of using the WEEKDAY function use DATEVALUE function and sort by the same column. Does that get you what you need?

 

 

WeekDayNum = DATEVALUE('Sample'[Date])

 

 

 

moizsherwani_0-1631964643753.png

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

I see that you get the result I need, but it does not allow me to sort WeekdayName by weekdayNum.

OlegV_0-1631965654726.png

 

moizsherwani
Continued Contributor
Continued Contributor

I think I found a bug in PowerBI, if you intitially setup the sort of WEEKDAYNAME to be by WEEKDAYNUM = WEEKDAY([date]) and then change the formula of WEEKDAYNUM = DATEVALUE([date]) it continue to sort correctly on the graph. If you try to sort it by column again then it gives this error. That said, this may not be the best solution so please find another solution below

 

Put the date on the X Axis and change the format of date to be 'ddd'. Make sure the X axis is changed from Continuous to Categorical. Also if you need to keep the oringinal date column as well you can simply make the WeekDayNum a duplicate of the Date column using = [Date]. Let me know if this works

 

moizsherwani_0-1631966286126.png

 

Thanks,

Moiz
Was I able to answer your question? Mark my post as a solution to help others. Kudos if you liked the solution.

It worked, thank you! So there are two ways to sort WeekDayName by Date
1) plot a column "Date" on an x-axis -> change format of a column "Date" to "ddd" -> change x-axis type from Continuous to Categorical;
2) create a column WeekDayNum using a formular = WEEKDAY('Table'[Date]) -> sort WeekDayName column by WeekDayNum -> change formular in WeekDayNum column to DATEVALUE('Table'[Date]).

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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