Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PSan1979
Helper II
Helper II

Sorting help

Hi Folks,

 

I am struggling to sort in order. please help.

 

#DaysBucket =
SWITCH (
TRUE (),
[DateDiff] <=1,"<0",
[DateDiff] >1 && [DateDiff] <= 30, "1-30",
[DateDiff] >30 && [DateDiff] <= 60, "31-60",
[DateDiff] >60 && [DateDiff] <= 120, "61-120",
[DateDiff] >120 && [DateDiff] <= 180, "121-180",
[DateDiff] >180 && [DateDiff] <= 240, "181-240",
[DateDiff] >240 && [DateDiff] <= 366, "241-366",
"Unknown"
)
 
Sorting.JPG
2 ACCEPTED SOLUTIONS
Tahreem24
Super User
Super User

@PSan1979 ,

Create one more switch column for sorting:

Sorting COlumn =
SWITCH(Table[Bucket],"<0",1,
"1-30",2,
"31-60",3,
"61-120",4,
"121-180",5,
"181-240",6,7)
Capture.PNG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

v-easonf-msft
Community Support
Community Support

Hi , @PSan1979 

It seems that  field "DateDiff"   is  a  calculated column or a measure?

Please sort column DateDiff   in ascending order first.

 

9.png12.png

 

Then  select and  sort  the column "DaysBucket2" by column" DateDiff", the result will show as below.

 

11.png13.png

 

Sample pbix attached

 

Best Regards,
Community Support Team _ Eason

 

 

 

 

View solution in original post

4 REPLIES 4
v-easonf-msft
Community Support
Community Support

Hi , @PSan1979 

It seems that  field "DateDiff"   is  a  calculated column or a measure?

Please sort column DateDiff   in ascending order first.

 

9.png12.png

 

Then  select and  sort  the column "DaysBucket2" by column" DateDiff", the result will show as below.

 

11.png13.png

 

Sample pbix attached

 

Best Regards,
Community Support Team _ Eason

 

 

 

 

Tahreem24
Super User
Super User

@PSan1979 ,

Or you can sort the bucket column based on SOrting COlumn which is created in my above post.

Go to Data tab (just above the relationship tab)  --> select BucketRange column --> go to "Column tool" menu --> Sort by COlumn option --> and choose "Sorting Order" column which just created.

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
amitchandak
Super User
Super User

@PSan1979 , I the same ways create a sort column with sequence 1,2,3 

 

2 #DaysBucket =
SWITCH (
TRUE (),
[DateDiff] <=1,1,
[DateDiff] >1 && [DateDiff] <= 30, 2,
[DateDiff] >30 && [DateDiff] <= 60, 3,
[DateDiff] >60 && [DateDiff] <= 120, 4,
[DateDiff] >120 && [DateDiff] <= 180, 4,
[DateDiff] >180 && [DateDiff] <= 240, 6,
[DateDiff] >240 && [DateDiff] <= 366, 7,
8
)

 

Or give space in names to sort in a particular order. In first give 6 space, 2nd one give 5 space

 

https://docs.microsoft.com/en-us/power-bi/desktop-sort-by-column

Tahreem24
Super User
Super User

@PSan1979 ,

Create one more switch column for sorting:

Sorting COlumn =
SWITCH(Table[Bucket],"<0",1,
"1-30",2,
"31-60",3,
"61-120",4,
"121-180",5,
"181-240",6,7)
Capture.PNG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.