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 / Sort PowerApps Gallery...
Power Apps
Answered

Sort PowerApps Gallery using Status Choice Column

(0) ShareShare
ReportReport
Posted on by 1,121

I have Status column in my SharePoint List with Choices New, In Progress and Completed. In my gallery I would like to show items sorted with this column. The "Completed" items needs to be at the end of the gallery. I would like to sort in the order of In Progress, New and Completed. I am not finding a way to do this for a choice column. What should be my approach for this? Below code is what I got for my Gallery items. 

 

SortByColumns(
 Filter(
 'SLD Form',
 (Category.Value = drpCategory.Selected.Value || If(
 drpCategory.Selected.Value = "All",
 true,
 false
 )) && (TopicType.Value = drpTopicType.Selected.Value || If(
 drpTopicType.Selected.Value = "All",
 true,
 false
 )) && (Status.Value = drpStatus.Selected.Value || If(
 drpStatus.Selected.Value = "All",
 true,
 false
 )) && If(
 varShowUpcmg,
 Schedule >= varToday,
 true
 )
 ),
 "Schedule",
 Descending
)

  

Also I dont think I would be able to use AddColumns Function as my gallery is linked to EditForm where there can arise conflict. I am really running out of options.

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @RameshMukka 

    Please consider changing your Formula to the following:

    DropColumns(
     SortByColumns(
     AddColumns( 
     Filter(
     'SLD Form',
     (drpCategory.Selected.Value = "All" || Category.Value = drpCategory.Selected.Value) &&
     (drpTopicType.Selected.Value = "All" || TopicType.Value = drpTopicType.Selected.Value) &&
     (drpStatus.Selected.Value = "All" || Status.Value = drpStatus.Selected.Value) &&
     ((varShowUpcmg && Schedule >= varToday) || !varShowUpcmg)
     ),
     "_sortOrder", Switch(Status.Value, "In Progress", 1, "New", 2, "Completed", 3, 4)
     ),
     "_sortOrder",
     Ascending
     ),
     "_sortOrder"
    ) 

    In the above (first the filter criteria is simplified), the column is added for the sort order.  Then the list is  sorted by that column.  Finally, since you have dependency on the schema of the Gallery records, the column is dropped.

     

    I hope this is helpful for you.

  • rameshmukka Profile Picture
    1,121 on at

    @RandyHayes  You are genius sir! It worked like a charm. Thank you so much. I have one more question regarding your formula. I have seen delegation warning regarding the filter i used for my date column "Schedule". But with your formula I dont see that. I didn't understand how? Can you explain a bit.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @RameshMukka 

    No problem!

    Yes, in your original formula you were using If's to determine variables and then doing criteria on Schedule.  This is not something that PowerApps can delegate, and thus the delegation warning.  In my formula, we just delegate the criteria and then we can AND that with the variable OR the NOT of the variable.  Result is the same, but PowerApps can delegate that.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 509 Most Valuable Professional

#2
Haque Profile Picture

Haque 302

#3
11manish Profile Picture

11manish 265

Last 30 days Overall leaderboard