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
schilders
Frequent Visitor

How to Ensure Slicer and Graphs are Sorted by Year and Month

I have a business object defined as follows:

 

DateFrom = 
ADDCOLUMNS (
CALENDAR(MINX('Auth Data','Auth Data'[Admit Date]),DATE(YEAR(MAXX('Auth Data','Auth Data'[Admit Date])),12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", FORMAT ( [Date], "MM" ),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & FORMAT ( [Date], "Q" ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" )
)

 

 

I use a slicer that includes Year, Quarter and Month.  How do I ensure all sort levels are correct?  When I sort by Month Number (a whole number), the slicer does not correctly sort as intended.  I want to sort by MonthNumber but only need the slicer to dispaly Year, Quarter and Month.

 

Additionally, the graphs in the dashboard that use the Year and Month do not render in chronological order.  How do I ensure that the values are plotted on the x-axis in year and month order?

4 REPLIES 4
schilders
Frequent Visitor

Thanks so much for your help.  After applying those sorts, my graph still does not render in precise chronological order.  I'm using the 12 months ending October 31, 2022 but the last x-axis value is December.  Can you suggest a workaround for this?

danextian
Super User
Super User

Hi @schilders ,

 

FORMAT function results  to a text  string so whatever the results are, they're sorted alphabetically. You can use use sort by another column in Power BI to do a custom sorting. Month as text is to be sorted by month number - MONTH(Dates[Date]) and Quarter to be sorted by the quarter number - ROUNDUP(MONTH([Date])/3, 0)










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

@danextian  Thanks for your response.  My modified DateFrom is as follows:

DateFrom = 
ADDCOLUMNS (
CALENDAR(MINX('Auth Data','Auth Data'[Admit Date]),DATE(YEAR(MAXX('Auth Data','Auth Data'[Admit Date])),12,31)),
"DateAsInteger", FORMAT ( [Date], "YYYYMMDD" ),
"Year", YEAR ( [Date] ),
"Monthnumber", Month([Date]),
"YearMonthnumber", FORMAT ( [Date], "YYYY/MM" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"MonthNameShort", FORMAT ( [Date], "mmm" ),
"MonthNameLong", FORMAT ( [Date], "mmmm" ),
"DayOfWeekNumber", WEEKDAY ( [Date] ),
"DayOfWeek", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"Quarter", "Q" & ROUNDUP( MONTH([Date])/3, 0), "Quarternumber", ROUNDUP( Month([Date])/3, 0 ),
"YearQuarter", FORMAT ( [Date], "YYYY" ) & "/Q" & FORMAT ( [Date], "Q" )
)

I've applied the sorts on the object as suggested and my slicer now works as intended.  What do you suggest in terms of addressing the chronological order of months on the x-axis of my graphs?  Snippet below after changes to DateFrom object:

PBI_Admits_Graph.PNG

 

PBI_Admits_Graph_Settings.PNG

 

Hi @schilders ,

 

Sort these two columns by Monthnumber

danextian_0-1669165582380.png

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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.