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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I sort combobox...
Power Apps
Unanswered

How do I sort combobox values when numbers are involved?

(0) ShareShare
ReportReport
Posted on by 634

I have a combox box hooked up to a CDS(Dataverse) table. The values are in the following format.

 

Item-1, Item-2...Item-20

 

When the comboxbox loads and is sorted Ascending it puts Item-10 right after Item-1. Is the only way to sort these correctly is to put a '0' in front of the single digit numbers? I'd run into issues again when I get to Item-100. That would be place right after Item-10

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Future_Vision 

    What is your Items property formula currently for the combobox?

  • Future_Vision Profile Picture
    634 on at

     

    @RandyHayes 

    Sort(ShowColumns('Details',"crfeb_detail"),crfeb_detail)

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Future_Vision 

     

    Consider the following then:

    DropColumns(
     SortByColumns(
     AddColumns(
     ShowColumns('Details', "crfeb_detail"),
     "num", Value(Match(crfeb_detail, MultipleDigits).FullMatch)
     ),
     "num"
     ),
     "num"
    )

     

    This will use regular expression matching to pull the digits out and then convert to numbers.

    It then sorts by the real numbers and finally drops the column we used to sort because we don't need it any more.

     

     

  • Future_Vision Profile Picture
    634 on at

    Ok. Mostly worked. I just realized I have some other items in there that break this somewhat. For example, to make this simple, I have Item-1...Item20 and Widget-1...Widget20. This code would put Widget-1 right after Item-1 then move onto Item-2 followed by Widget-2. I'd want to keep the Item-N together and the Widget-N together.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Future_Vision 

    There ya go...leaving out details!! 🤣🤣

     

    Give this a shot:

    DropColumns(
     SortByColumns(
     AddColumns(
     ShowColumns('Details', "crfeb_detail"),
     "num", Value(Match(crfeb_detail, MultipleDigits).FullMatch),
     "nm", Match(crfeb_detail, MultipleLetters).FullMatch
     ),
     "nm", Ascending, "num"
     ),
     "num", "nm"
    )

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard