Forum Discussion
How to Get Dates in correct order
Hello community,
I'm very new to Power BI.
I have imported a dataset into Power BI desktop.
I have created a Line Chart visual. The actual values are correct, but I can't appear to get the order of the dates correct.
Can someone take a look at the visual and let me know where I might be going wrong.
The data is as follows:
My line chart is as follows:
The measure looks like the following:
Let me know if you need the PBIX?
Thanks
- Anonymous2 years ago
Hi caplogic ,
I created some data:
Thank PowerBigginer for sharing, and here’s a method I’d like to share with you all:
Power BI's default sorting is alphabetical, so you'll need to create a [Month] column and an [Index] table for sorting.
Here are the steps you can follow:
1. Create calculated table.
Table 2 = var _table1= CALENDAR( DATE(2023,1,1),DATE(2023,12,31)) var _table2= ADDCOLUMNS( _table1,"Month",FORMAT([Date],"mmm")) return SUMMARIZE( _table2,[Month],"mindate",MINX(FILTER(_table2,[Month]=EARLIER([Month])),[Date]))2. Joining a relationship between two tables
3. Select [Month] – Column tools – Sort by column – [mindate].
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
4 Replies
- PowerBigginer
Helper II
Create Month Num column in your date table
MonthNum = MONTH(DimDate[CalendarDate])
then give sort order MonthNim to your Month Name columnthen add MonthName to your Line chart
If it helps Please Mark as a solution
For more power bi tips and tricks visit https://powertipstricks.blogspot.com/
Thanks & Regards
- caplogic
Helper II
Hi PowerBigger,
Thanks for getting in touch.
I tried your suggestion, but it doesn't appear to be working.
See screenshots below:
- PowerBigginer
Helper II
Dax Error please check your table I guess you don't have date column in your table try this way
MonthNumber = MONTH(DATEVALUE('DimDate'[MonthName] & " 1"))
in bolded text please replace with your table and column names
- AnonymousNot applicable
Hi caplogic ,
I created some data:
Thank PowerBigginer for sharing, and here’s a method I’d like to share with you all:
Power BI's default sorting is alphabetical, so you'll need to create a [Month] column and an [Index] table for sorting.
Here are the steps you can follow:
1. Create calculated table.
Table 2 = var _table1= CALENDAR( DATE(2023,1,1),DATE(2023,12,31)) var _table2= ADDCOLUMNS( _table1,"Month",FORMAT([Date],"mmm")) return SUMMARIZE( _table2,[Month],"mindate",MINX(FILTER(_table2,[Month]=EARLIER([Month])),[Date]))2. Joining a relationship between two tables
3. Select [Month] – Column tools – Sort by column – [mindate].
4. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly