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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Sorting Column based on the another column

Hi All,
We have data like below image :-

Yagevendra_0-1651574061693.png

 



Based on the sort range column I want to create one another column where sort range contains “>-“ it will be 1 and if sort range contains “>” it will be max value of the sort range rest remain same in new column.

It will helpful if I do the changes in same column “sortrange”
This column I have created to sort the “Range”.



1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Please check the formula.

Column =
IF (
    CONTAINSSTRING ( 'Table'[range], ">-" ),
    "1",
    IF (
        CONTAINSSTRING ( 'Table'[range], ">" ),
        SUBSTITUTE ( 'Table'[range], ">", "" ),
        'Table'[short range]
    )
)

vjaywmsft_0-1651815455151.png

 

Best Regards,

Jay

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

 

Please check the formula.

Column =
IF (
    CONTAINSSTRING ( 'Table'[range], ">-" ),
    "1",
    IF (
        CONTAINSSTRING ( 'Table'[range], ">" ),
        SUBSTITUTE ( 'Table'[range], ">", "" ),
        'Table'[short range]
    )
)

vjaywmsft_0-1651815455151.png

 

Best Regards,

Jay

Singaravelu_R
Resolver III
Resolver III

First duplicate the shortRange column in the query editor then replaces >- values into = as given below

Singaravelu_R_0-1651580782469.png

then split the column by non digit to digit and close and apply

 

Singaravelu_R_1-1651580949739.png

then create calucate column like below

Column = if('Table'[shortRange - Copy.1]="=","1",if('Table'[shortRange - Copy.1]=">",max('Table'[shortRange - Copy.2]),'Table'[shortRange]))
Singaravelu_R_2-1651581277175.png

 

amitchandak
Super User
Super User

@Anonymous , Looking at data remove > signs , trim space and covert to number, best can done in power query using replace values and trim under data transform

 

Power Query Trim and Clean: https://youtu.be/NRYPsCnS0w4

Power Query Replace Value: https://youtu.be/hkZhZbR7Kmk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak , There is tow 17000 and >17000 presented in data
based on the sort of range, I am trying to sort "Range" column, If I am remove > sign from the column and trying to sort "Range" column based on "Sort Range" column there will be conflict between 2 rows
It will showing me x axis like this on data:

Yagevendra_1-1651582672729.png

 


>-20000 should be palace on 1st position.

Helpful resources

Announcements
FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.