GroupÂing Data
- When makÂing charts/graphs, you can sort your data via groups â but groups are staÂtÂic and will have to be manÂuÂalÂly updatÂed if you add more data to your visuÂal (For examÂple, numÂber of peoÂple in age ranges). Instead, use calÂcuÂlatÂed columns and refÂerÂence those as your axis instead. SamÂple code:
IF([Age]<31, "0-30",
IF(31<= [Age] && [Age] < 61, "31-60",
IF(61 <= [Age] && [Age] < 91, "61-90",
IF(91 <= [Age] && [Age] < 121, "91-120", "Over 120"))))
- SynÂtax: IF([condition], â[label]â, â[else label]â)
- Above uses nestÂed IFâs
- * Note: CanÂnot group meaÂsures for cusÂtomized visuÂal disÂplay. GroupÂing this way only works for indiÂvidÂual columns, to the extent of my underÂstandÂing
CusÂtom Sort Axis Labels
- PowÂer BI does not have an easy way to cusÂtom sort axis labels either as of the writÂing of this docÂuÂment. CurÂrentÂly the quick and dirty way around it is to use periÂods at the beginÂning of axis titles.
- ExamÂple: months of the year
- JanÂuÂary, FebÂruÂary, March, and April would be auto sortÂed as April, FebÂruÂary, JanÂuÂary, March. To solve this, the workaround is to name them as such: ââŚJanÂuÂaryâ, â..FebÂruÂaryâ, â.Marchâ, âAprilâ
- The cleanÂer method is to make a new colÂumn in your query, and treat it as an index for your axis labels. ConÂtinÂuÂing with the months examÂple:
- ExamÂple: months of the year
1. Top RibÂbon > Home > Edit Queries > Select your table/Query on the left
2. Right click on and dupliÂcate your Month colÂumn
3. On the dupliÂcatÂed colÂumn (By default, âMonth â Copyâ. I like to rename it as âMonth â Indexâ), right click and choose âReplace ValÂuesâ
4. ValÂue To Find: JanÂuÂary
â Replace With: 1
â OK
5. Repeat with all months, until the âMonth â Copyâ colÂumn conÂtains only numÂbers 1 â 12.
6. Change data type to Whole NumÂbers
7. Close & Apply
8. Under Fields, go to your table and click on the Month colÂumn

9. Go to ColÂumn Tools in the ribÂbon, then âSort by ColÂumnâ
- If the butÂton is greyed out, make sure youâve clicked on the Month colÂumn

10. Select âMonth â Indexâ (your dupliÂcatÂed colÂumn).
11. Your visuÂal should now disÂplay the months in the corÂrect order, withÂout havÂing to use periÂods
â ThorÂough explaÂnaÂtion here: https://www.câsharpcorner.com/article/sort-by-month-name-in-power-bi/ or archived through the wayÂbackÂmaÂchine: https://web.archive.org/web/20190723215646/https://www.câsharpcorner.com/article/sort-by-month-name-in-power-bi/