web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Trouble with Sort function

(1) ShareShare
ReportReport
Posted on by 173

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

I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at
    Re: Trouble with Sort function

    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
    173 on at
    Re: Trouble with Sort function

    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
    173 on at
    Re: Trouble with Sort function

    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,921 on at
    Re: Trouble with Sort function

    @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,228 Most Valuable Professional on at
    Re: Trouble with Sort function

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 766 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 419 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 235

Last 30 days Overall leaderboard