cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
racheljgood119
Level: Powered On

Filtering and Sorting a gallery

Filter and Sort.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I want people to be able to filter previous records while filling out a form. I have a form and then a little browse gallery on the side that displays previous records based on the student name selected in the dropdown box. I did this by placing a little text label in the upper right side of the gallery where the Text property= datacardvalue3.selected.value. Then I set the gallery property to filter based on that text label so it would only display records for the selected student name. I used Filter('CLMS 6th Discipline Records 1718', Label2.Text in Student_x0020_Name.Value). My problem is that I would like the gallery to also sort the records by the subtitle "1st offense: Warning", "3rd offense: silent lunch", which represents the column name Discipline_x0020_Step.  But I cannot seem to nest the formulas properly for the gallery to do so. 

 

When I type Sort('CLMS 6th Discipline Records 1718', Discipline_x0020_Step.Value, Ascending), the gallery sorts based on this column and all is well, but I cannot get it to sort AND filter. Any ideas? 

1 ACCEPTED SOLUTION

Accepted Solutions
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Filtering and Sorting a gallery

You can combine both the Filter and the Sort operations in the same expression. Something along the lines of

Sort(
    Filter(
        'CLMS 6th Discipline Records 1718',
        Label2.Text in Student_x0020_Name.Value),
    Discipline_x0020_Step.Value,
    Ascending)

View solution in original post

3 REPLIES 3
Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Filtering and Sorting a gallery

You can combine both the Filter and the Sort operations in the same expression. Something along the lines of

Sort(
    Filter(
        'CLMS 6th Discipline Records 1718',
        Label2.Text in Student_x0020_Name.Value),
    Discipline_x0020_Step.Value,
    Ascending)

View solution in original post

racheljgood119
Level: Powered On

Re: Filtering and Sorting a gallery

That worked! I don't know you but I LOVE YOU!

BradieO
Level: Powered On

Re: Filtering and Sorting a gallery

What if I wanted to add Distinct into this code, where would it go? I can get Distinct +Filter to work, I can get Sort+Filter to work.  I cannot get all 3 to work when I am filtering from a gallery.  For example Filter(Table, Column=Gallery2.Selected.Result)

I have tried this in all orders and I get 2/3 to work.  Here's one attempt:

 

Distinct(PIETopics,Sub_Category,
(Sort(PIETopics,"Sub_Category", Ascending),
(Filter(PIETopics,Primary_Category=Gallery2.Selected.Result))

Helpful resources

Announcements
thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors
Users online (6,185)