Forum Discussion
Sorting Issues for a Bar Chart
- 8 years ago
Regarding the first sort, is a field from a DIM table (like an item master, customer master) on the axis of the bar chart? the sort by options wont' show up if you are using a field from the FACT table (like a customer key in a sales table). In that example, use the customer number/name from the Customer master table.
On the second sort, in a table I assume, get rid of the fake column where you muitiplied by -1. Sort by the comparison column. then sort again. It toggles from A..Z to Z..A each time you sort.
- 8 years ago
Here is a decent article on it.
In summary, a FACT table are your facts - the sales data for example. A sales table might have a customer number, item number, invoice number, invoice date, quantity, and amount.
A DIM table are your dimensions, or sometimes called master tables. So a customer master/DIM table would have your customer number, customer name, address, zip code, phone number, etc.
In Power BI and Excel with Power Pivot, you want those in separate tables. Before Power Pivot, you had to put all of that in one big flat table so Excel's Pivot Table function worked.
With Power BI and Power Pivot, you want those in separate tables, then you join them. This page has a pretty good overview of joining and how you'd use a Star Schema pattern (FACT table in the middle, DIM tables around it) when joining. Power BI works best with a Star Schema.
Once you set up relationships in Power BI, it knows a DIM table is on the One side of the relationship and a FACT table is on the Many side. It figures that out based on the unique values in the field being joined. A date table is a DIM table.
As to sorting things by some sort of date (month name, week name, day name, whatever) you generally need to use the Sort by Column feature on the modeling tab. I usually have other fields in my date table that are strictly numeric so I can sort calendar names by something other than alphabetically.
Yes, I am with you on the number vs name thing. While I have Day Name as the axis labels, I also have a numeric column in my date table that indicates 1 for Monday through 7 for Sunday. Then I select the field 'Day of Week', the numeric field, go to "Sort by Column" in the Modeling menu item. There, it shows "Day of Week" as the default (why, I'm not sure). Even if I click that again to try to make the sort change, nothing happens. The day names are still unsorted. Actually, now that I look at it, that is not exactly true, the data are sorted in descending order by the value being charted. If I change the axis to be the numeric 'Day of Week' it sorts just fine, 1 through 7, in order.
- edhans8 years agoCommunity Champion
If it is sorted descending, just click sort again in the desktop app before publishing. I think the July 2018 update added a clear A-Z/Z-A sort selection, but prior to that you just hit sort again and it toggled from A-Z and Z-A. Not 100% sure on the exact way to do it. I'm on my mac right now, and no PBI desktop app to check.