Showing results for 
Search instead for 
Did you mean: 
Not applicable

Sorting by numerical order

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?

Super User
Super User


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.




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."

Not applicable

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

The Distinct function always returns a single column called Result. That’s why you don’t see the other columns.
Not applicable

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?

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.

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.
Community Support
Community Support

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:

Substitute(teams,"Team n°: 1 - [",""),

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:

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



Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Not applicable

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

New Member


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

Helpful resources

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (1,619)