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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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)





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

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


"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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors