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

Notifications

Announcements

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,297 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard