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 / Sorting by numerical o...
Power Apps
Unanswered

Sorting by numerical order

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi guys,

 

I was wondering, is there any way to sort galleries, dropdowns etc... by numerical order? In an app that I am building, I have a list of "teams" basically. In my share point, they are listed like so : "Team n°: 1 - [Team Name]". I want to display all the teams in numerical order so Team n°1 first then 2,3,4.... Everything is good from 1 to 9 but when you get to ten, it does not work anymore.

It displays 1,10,11,12...19,2,21... you get the idea.

 

Is there a way around this?

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @Anonymous 

    Your gallery displays in the order 1,10,11,12...19,2,21... because TeamNumber is a Text column.

     

    You could make a Gallery with Teams as the datasource and input the following code into the Items property to convert TeamNumber to a Number type value on the fly.

     

    Sort(NumberTest,Value(TeamNumber),Ascending)

     

    The problem with this formula is wrapping TeamNumber in the Value formula gives a delegation warning.  This will only work up to 500 lines in the Teams table.

     

    Therefore, the only real way to solve this is to change the TeamNumber column to a Number column rather than a Text column in your datasource.

     

    ---
    Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I know it is a text column so I made another column with jsut the numbers and I wanted to sort my text team column taking into account the number column it is related to but does not seems to work.

    SortByColumns(Distinct('Tableau de bord ST_1';'Lots concernés');"Result"). This is what I typed but I can only chose result at the end and not the number column

  • mdevaney Profile Picture
    29,991 Moderator on at
    @Anonymous
    The Distinct function always returns a single column called Result. That’s why you don’t see the other columns.
    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-distinct
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    So I cannot do distinct and sort by another column ?

    The problem I have is I dont want do change the column type to number because then it wont display the team names just numbers, isnt it?

  • mdevaney Profile Picture
    29,991 Moderator on at
    @Anonymous
    Correct. Distinct returns only one column. You have two options here.

    1. Add a new Number type column called TeamNumber and sort by it instead.

    2. Use the GroupBy function instead of Distinct. I can write out the full solution on a mobile phone but here’s a link to another forum post. https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Distinct-with-multiple-columns/td-p/322204

    —-
    Please mark this post as Solution if it answered your question so others may find it more quickly. If you found this post helpful consider giving it a Thumbs Up.
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Do you want to sort a text type columns based on the number inside it?

    I suggest you try AddColumns function to shape tables( not affect the original data).

    Try this formula:

    SortByColumns(
    AddColumns(tablename,"number",Value(
    Substitute(
    Substitute(teams,"Team n°: 1 - [",""),
    "]","")
    )
    )
    ),"number")

    In the formula, I create a new field that only records the team number.

    And then, sort the new table based on the number field.

    Here's a doc about shaping table for your reference:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-table-shaping

    Here's a doc about formatting text(in this example is replacing "Team n°: 1 - [...]" with "") for your reference:

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-replace-substitute

     

     

    Best regards,

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I tried your strategies but it seems I cannot pull it off, it won't sort the way I want. So I just put away the number idea.

     

    Sorry for the inconvenience, thank you for the help anyways

  • Jefpoy Profile Picture
    2 on at

    Hello,  

    First let me say that I am a "BRAND NEW" user to PowerApps so please be patient with me.   I have read through the comments and don't quiet understand all of the technical explanations given, so I have attached an image of what I need help on.  

    I have a PowerApp tied to a Sharepoint list.  My list is organized by an Activity number.  I want my PowerApp to sort the items by this number.  I have two questions:  First, Can this be done?, and Secondly can someone explain it in a way that a very new user can understand.  

    Thanks in advance for any help.Power app example.JPG

  • kgordish Profile Picture
    193 on at

    I discovered this issue. I was trying to build a custom sort by using a calculated SharePoint column.

    Discovered sorting issue In Power Apps with 1, 10, sort problem when I really wanted. 1,2,3...9, 10, 11.

     

    Since I had only 15 categories, I switched to letters. Side-stepped this problem.

     

    =IF(SharePoint Column="Field","A",
    IF(SharePoint Column="Field","B",
    IF(SharePoint Column="Field","C",
    IF(SharePoint Column="Field","D",
    IF(SharePoint Column="Field","E",
    IF(SharePoint Column="Field","F",
    IF(SharePoint Column="Field","G",
    IF(SharePoint Column="Field","H",
    IF(SharePoint Column="Field","I",
    IF(SharePoint Column="Field","J",
    IF(SharePoint Column="Field","K",
    IF(SharePoint Column="Field","L",
    IF(SharePoint Column="Field","M",
    IF(SharePoint Column="Field","N",
    IF(SharePoint Column="Field","O"))))))))))))))

  • ferby2023 Profile Picture
    45 on at

    I was struggling to solve this and found your answer! Thank you so much!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 136 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 109 Super User 2026 Season 2

Last 30 days Overall leaderboard