Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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:
  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: How do I sort combobox values when numbers are involved?

    @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"
    )
  • Future_Vision Profile Picture
    634 on at
    Re: How do I sort combobox values when numbers are involved?

    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,287 Super User 2024 Season 1 on at
    Re: How do I sort combobox values when numbers are involved?

    @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
    Re: How do I sort combobox values when numbers are involved?

     

    @RandyHayes 

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

     

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on at
    Re: How do I sort combobox values when numbers are involved?

    @Future_Vision 

    What is your Items property formula currently for the combobox?

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard