cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Devildez
Level: Powered On

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?

8 REPLIES 8
Super User
Super User

Re: Sorting by numerical order

@Devildez 

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

Devildez
Level: Powered On

Re: Sorting by numerical order

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

Super User
Super User

Re: Sorting by numerical order

@Devildez
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
Devildez
Level: Powered On

Re: Sorting by numerical order

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?

Super User
Super User

Re: Sorting by numerical order

@Devildez
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/...

—-
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 Team
Community Support Team

Re: Sorting by numerical order

Hi @Devildez ,

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 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.
Devildez
Level: Powered On

Re: Sorting by numerical order

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
Level: Power Up

Re: Sorting by numerical order

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

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,507)