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 / Sorting Gallery by Sha...
Power Apps
Answered

Sorting Gallery by SharePoint Choice column

(0) ShareShare
ReportReport
Posted on by 240

Hello:

I have a gallery with 'multiselect' sorting capabilities :

 

nemanjasovic011_1-1659544916368.png

 

The arrows change the value of the VarColoumn variable and dictate on which column the gallery will be  sorted as per this tutorial . Now everything works apart from Task Status column, which is choice column How would I pass the values from icon 'on-select' to gallery items property, and sort the gallery by choice field? I am suppling code for Gallery items and for the 'sorting icon'(this code works on all fields apart from 'Task Status" choice column). Please note that the Search function is imbedded in the Sortybycoloumn as there is a (functional)search control. 

 

Code for Gallery filter: * please note that I have appended column for choice 

SortByColumns(
 If(
 !IsBlank(Search_tb.Text),
 Search(
 AddColumns(
 ActiveLAFRequests,
 "StatTask",
 'Task Status'.Value
 ),
 Search_tb.Text,
 "Title",
 "Brand",
 "Varietal_x0028_s_x0029_",
 "Vintage",
 "Fanciful",
 "AVA_x002f_Appellation_x0028_s_x0",
 "StatTask"
 ),
 ActiveLAFRequests
 ),

 VarSortColoumns, //varibales 
 VarSortDirection
 
)

 

Code for icon on choice column

Set(
 VarSortColoumns,
 "StatTask"
);
Set(
 VarSortDirection,
 If(
 VarSortDirection = Ascending,
 Descending,
 Ascending
 )
);

:

 

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

    @nemanjasovic011 

    The issue is that you are switching record schema in your Items property by using that If statement.  It is not needed as if the Search Text is blank, then it will already return what you want.

    Your Items property Formula for the Gallery should become:

    SortByColumns(
     Search(
     AddColumns(ActiveLAFRequests,
     "StatTask", 'Task Status'.Value
     ),
     Search_tb.Text, "Title", "Brand", "Varietal_x0028_s_x0029_", "Vintage", "Fanciful", "AVA_x002f_Appellation_x0028_s_x0", "StatTask"
     ),
     VarSortColoumns, 
     VarSortDirection
    )

     

    The Formulas you have on the Icon are fine.

     

    I hope this is helpful for you.

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard