Forum Discussion
How to Sort Bar Chart by Month Number from Live Query but Not Show On Chart
- 1 year ago
ā
I re-created your problem and was able to get the X axis to sort correctly per your specifications.
Make sure the visual is sorted according to the Month and Year column as well.
See the attached .pbix file, perhaps you can reverse engineer it to see where you went wrong.
///Mediocre Power BI advice, but it's free///
- 1 year ago
You are correct that there is no need to add it to the tool tip.
Did you download the .pbix file I created for you? It has everything done, all you need to do is compare and find the difference between your file and mine.
Check everything to make sure you're doing it the same way. Check the data types of the columns, make sure Month_And_Year is sorted by year_month, and that year_month is formatted as a whole number, check the connection between the date table and the fact table in your semantic model, etc.
You can create these columns in whatever table you're already using, I'm just saying that Power BI best practice includes the creation of a Date Dimension table in your semantic model, with active connections to all of your other tables. No need to use joins of any kind.
Ideally your date dimension table would have a column of dates which you use to create the active connections, then calculated columns based on that date field. It is these calculated columns that you then use in your visuals.
You could create one like so:
Date_Table = CALENDAR(DATE(2020, 1, 1), DATE(2030, 12, 31))
That would create a Date Table with a single column, all dates between Jan 1 2020 and Dec 31 2030.
You then create the active connection between that date column and the date columns in all of your other tables.
The purpose is so that as you continue to bring in more data sources, you can more easily create metrics that use data from multiple tables.
example, you have a revenue and an expense table. You want to graph, by month, profit.
You could create a single measure:
profit = COALESCE(SUM(revenue[dollars]), 0) - COALESCE(SUM(expense[dollars]), 0)
then use that measure in a visual, with the X axis being the calculated Month column from your Date Dimension table.
Hi, I went ahead and created a date table, and on the x-axis assigned the field "Month Year" from the date table. However, I still cannot sort it correctly based on the "Year Month" field of the date table, even when I use Column tools and sort based on that column.
- kpost1 year ago
Solution Sage
ā
I re-created your problem and was able to get the X axis to sort correctly per your specifications.
Make sure the visual is sorted according to the Month and Year column as well.
See the attached .pbix file, perhaps you can reverse engineer it to see where you went wrong.
///Mediocre Power BI advice, but it's free///
- MorningSwim1 year agoRegular Visitor
If I sort both the Date Table by column Month Year as well as the visual I get this:
This makes sense to me, because it's basically in alphabetical order, which is not how we want it. I can force it by adding the Year Month (YYYY-MM) field in the toll tip and then sorting by that, but that doesn't seem like it would be the right approach.
- kpost1 year ago
Solution Sage
You are correct that there is no need to add it to the tool tip.
Did you download the .pbix file I created for you? It has everything done, all you need to do is compare and find the difference between your file and mine.
Check everything to make sure you're doing it the same way. Check the data types of the columns, make sure Month_And_Year is sorted by year_month, and that year_month is formatted as a whole number, check the connection between the date table and the fact table in your semantic model, etc.