cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
racheljgood119
Helper I
Helper I

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
CarlosFigueira
Power Apps
Power Apps

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
CarlosFigueira
Power Apps
Power Apps

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

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

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (2,899)