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 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,297 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,297 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,297 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

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 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard