cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LennartWalldén
Helper II
Helper II

Trouble with Sort function

Hi,

 

I am working on a quite big app for Project management. One of our items is to defin which of the Global Goals we are supporting with the actual project. I have a Sharepoint field with the 17 goals listed like "01. No poverty"; "02. No hunger" etc. When the user picks the proper items I want to show the chosen values in a Gallery which sorts the values in ascending order from 01 to 17.

I have a dropdown Combobox with the goals in text, which is a Choices field from SP, and then I have the Items property in the Gallery set like this: Sort(Globala_mal_value.SelectedItems.Value;Ascending) and the result looks like in the attached pic.
The results are displayed in the order the User picked them.

How should I get them sorted?

 

Best,
Lennart

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks again Sancho

You got me on the right track! I replaced the Table with the Field name from SP , and set the Coulmn Name to "Value"and now it works! 😀 The code looks like this: 

SortByColumns(FN_x0020_globala_x0020_m_x00e5_l.Value;"Value";Ascending)
(I know it's a weird Column name, but we created it some years ago before we started to use PowerApps.)

Again, thanx a lot!

Regards,

Lennart

View solution in original post

5 REPLIES 5
iAm_ManCat
Super User
Super User

Hi @LennartWalldén 

 

As this is from a SharePoint source, have you tried sorting by column - currently you are doing a sort, ascending on the SelectedItems, which are already sorted by their selected (I know, the logic for that makes no sense like why would you want it sorted by what they chose when its already that).

 

Could you try:

SortByColumns(Globala_mal_value.SelectedItems.Value; "ColumnName"; Ascending)

 

Let me know if that works for you,

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Thanks Sancho!

No, I am sorry, that didn't work either. I see what you mean, that it's already sorted, but I still can't figure out how to get it displayed the way I want.

Do you think I could collect the values into a Collection or similar and sort that collection, and then display the collection instead?

Do you know what that code would look like?

Regards,
Lennart

Thanks again Sancho

You got me on the right track! I replaced the Table with the Field name from SP , and set the Coulmn Name to "Value"and now it works! 😀 The code looks like this: 

SortByColumns(FN_x0020_globala_x0020_m_x00e5_l.Value;"Value";Ascending)
(I know it's a weird Column name, but we created it some years ago before we started to use PowerApps.)

Again, thanx a lot!

Regards,

Lennart

@LennartWalldén 

I think @iAm_ManCat  deserve your Kudos for putting you on the right track as you said.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Hey @LennartWalldén 

 

Glad I could help you in the right direction - Thanks for coming back with the solution, really appreciate that as this will help others in future if they face similar issues 🙂

 

And haha, no worries about the column name, at my company we have so many SharePoint lists so there are loads of staff who used long names before SharePoint started removing spaces 🙂

 

Cheers,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,791)