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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (57,968)