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
flyinggnugget
Frequent Visitor

Sorting column that contains both Text and Numeric values

I have two columns, one contains a mixture of text and numeric values, the other column contain boolean values on whether the first column is numeric or not. Values column is currently set as text format.

Example:

ValuesIs Numeric

Yes

False
1True
Matthew is 12 years oldFalse
2True
JonathanFalse
11True

 

As the values column contains text, when I try to sort it, it will sort as text format as seen in the following example, which is fine.

Example of sorted table:

ValuesIs Numeric
1True
11True
2True
JonathanFalse
Matthew is 12 years oldFalse
YesFalse

 

Is there a way I can get the values column to sort as number format when I filter for only numeric values?

Example of sorted when applying filter for Is Numeric = True:

ValuesIs Numeric
1True
2True
11True

 

Thanks for looking into this. Appreciate it

3 REPLIES 3
v-xinruzhu-msft
Community Support
Community Support

Hi @flyinggnugget 

You can create a calculated column

 

Rank =
IF (
    [Is Numeric] = TRUE (),
    RANKX (
        FILTER ( 'Table', [Is Numeric] = TRUE () ),
        VALUE ( [Values] ),
        ,
        ASC,
        DENSE
    ),
    RANKX ( FILTER ( 'Table', [Is Numeric] = FALSE () ), [Values],, ASC )
)

 

 

Output

vxinruzhumsft_0-1700460910302.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ahmedx
Super User
Super User

It would be better if you do it in power query like this

Screenshot_3.png

Ahmedx
Super User
Super User

pls try this

Screenshot_2.png

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.