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 / Trouble with Sort func...
Power Apps
Answered

Trouble with Sort function

(1) ShareShare
ReportReport
Posted on by 181

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

Sort error.png
Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    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

  • LennartWalldén Profile Picture
    181 on at

    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

  • Verified answer
    LennartWalldén Profile Picture
    181 on at

    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

  • eka24 Profile Picture
    20,925 on at

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

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    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

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard