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.
So create a reference table (2 fields, month number and month name), join it on the custom column month number from my main table, and then sort on the reference table?
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.