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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
jaryszek
Valued Contributor II

How to sort chart by 3 date columns?

Hello,

I have model like that:
 

jaryszek_0-1758034388763.png

 

and I am using Dates columns here to create date hieararchy:

jaryszek_1-1758034433345.png


And now i got not ordered items in visual after adding date hierarchy with sum of costs:

jaryszek_2-1758034469892.png


i tried to use custom sort order from Column tools for each Hierarchy Item but it is failing:

jaryszek_3-1758034520332.png


I am trying to use DateKey (integer) as sort column but it is complaining. 
What is the best practice to solve the case? 

Attaching model from my google disc - will be easier:

https://drive.google.com/file/d/13wn-vSyg5q2mvU5KtWzMSiPZWHDHGxVR/view?usp=sharing


Best,
Jacek

 

 

 

 

1 ACCEPTED SOLUTION
MasonMA
Valued Contributor II

Hi Jacek, the MonthName is of Text data type. By default, Power BI sorts text alphabetically (Apr, Aug...) so it's why we sort this column by a numeric column.

 

While Day and Year are both stored as Whole Number. Numbers naturally sort in ascending order (1, 2, 3โ€ฆ or 2023, 2024โ€ฆ), so Power BI doesnโ€™t need a helper column.

 

View solution in original post

4 REPLIES 4
MasonMA
Valued Contributor II

Could you try first changing your Data Type for 'Day' and 'Year' Column from 'Text' to 'Number' under table view? then for the visual you either can add 'Date' to tooltip and sort axis by Date in Tooltip, or go back to Table view and sort by 'MonthName' column by 'MonthNum'. I think either way will give you correct date order on visual. 

MasonMA_1-1758036932796.png

 

 

jaryszek
Valued Contributor II

thanks. 

I tried both methods and they worked. 

Can you explain how this "go back to Table view and sort by 'MonthName' column by 'MonthNum'" is working ?

Why Days and Years accordingly adjusted? 

Best,
Jacek

MasonMA
Valued Contributor II

Hi Jacek, the MonthName is of Text data type. By default, Power BI sorts text alphabetically (Apr, Aug...) so it's why we sort this column by a numeric column.

 

While Day and Year are both stored as Whole Number. Numbers naturally sort in ascending order (1, 2, 3โ€ฆ or 2023, 2024โ€ฆ), so Power BI doesnโ€™t need a helper column.

 

jaryszek
Valued Contributor II

thanks!

Helpful resources

Announcements
Users online (11,084)