web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to sort text field...
Power Apps
Answered

How to sort text field with special characters like < in it

(0) ShareShare
ReportReport
Posted on by 52
I have a text field called 'Failed rate'. It is of type text and will be in the format like "<2%", "2%" . 
I want to sort this field such that <1% comes before 1% and so on. 
When I apply SortByColumn() function it is partially working as the additional string don't allow the sort to work properly.
How to get the number value alone and how to apply sort for the gallery? 
Categories:
I have the same question (0)
  • Suggested answer
    Nandit Profile Picture
    1,568 Moderator on at
    Hi
     
    Here's how you can achieve this:
    In the Items property of you gallery, modify and insert the following code:
    With(
        {
            Records: AddColumns(
                YourTable,
                Value,
                If(
                    StartsWith(
                        'Failed rate',
                        "<"
                    ),
                    Mid(
                        'Failed rate',
                        2,
                        1
                    ) + 0.1,
                    Left(
                        'Failed rate',
                        1
                    ) + 0.2
                )
            )
        },
        Sort(
            Records,
            Value,
            SortOrder.Ascending
        )
    )
    Your data will look like this:

    Before adding the Value column and sorting:


    After adding the Value column and sorting:

     
     
    Hope this helps. 
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     
  • CU10090150-0 Profile Picture
    52 on at
    Great! This works well for single digit values, but there are a few 2 digit values. like 51%, 11 %. These values are displaying based on the first digit, say 51 is showing along with 5, 11 along with 1. Is there anyway to include both digits in the conversion? 
  • Verified answer
    CU10090150-0 Profile Picture
    52 on at
    I included the length of the field in the condition and it worked perfectly for higher numbers as well.
    If(
                    StartsWith(
                        failedrate,
                        "<"
                    ),
                    Mid(
                        failedrate,
                        2,
                        1
                    ) + 0.1,
                    If(Len(failedrate) <3,
                    Left(
                        failedrate,
                        1
                    ) + 0.2,Left(failedrate,2)+0.2)
                ))
     
    Thank you @Nandit

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard