Forum Discussion
MarkianLC
3 years agoNew Member
Sorting on X axis on created column
Hello, Am in need of assistance....I have a query returning "Elapsed minutes" as Whole Number data type. I created a new column, within PowerBI, which "categorizes" the value into "buckets of time"....
- 3 years ago
Did you set the TimeSlot column to be sorted by the ID column?
lbendlin
3 years agoSuper User
First thing to do is create a reference table with your desired buckets and another column indicating the sort order.
Then you can sort the bucket name by the bucket ID
Note: You can slightly simplify your formula
Time_Slot = SWITCH(TRUE()
,Mobile_Visit_Detail[Elapsed Time]<=10,"0-10"
,Mobile_Visit_Detail[Elapsed Time]<=15,"10-15"
,Mobile_Visit_Detail[Elapsed Time]<=30,"15-30"
,Mobile_Visit_Detail[Elapsed Time]<=60,"30-60"
,Mobile_Visit_Detail[Elapsed Time]<=180,"60-180"
,Mobile_Visit_Detail[Elapsed Time]<=360,"180-360"
,Mobile_Visit_Detail[Elapsed Time]<=540,"360-540"
,Mobile_Visit_Detail[Elapsed Time]<=720,"540-720"
,"720 +")
MarkianLC
3 years agoNew Member
Thank you. However, the sorting is still not as intended.
I created the table as such:
MVTimeSlots = {
(1,"0-10", 1)
,(2,"10-15",2)
,(3,"15-30",3)
,(4,"30-60",4)
,(5,"60-180",5)
,(6,"180-360",6)
,(7,"360-540",7)
,(8,"540-720",8)
,(9,"720 +",9)
}
................................
Then, made the relationship from the "data" table to the created table.
The updated visual is still displaying incorrectly. The visual's axis field has the "TimeSlot" and "Order" columns from the created table MVTimeSlots.
Not able to sort the Axis by "Order".
Am using PowerBI Report Server version Version: 2.100.1381.0 64-bit (January 2022).
Here's the visual:
- lbendlin3 years agoSuper User
You now need to put the text from the reference table into the X axis, not from the data table.
see attached for a simplified version.