cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AdamH
Helper V
Helper V

Sort Gallery Data

Hi All, 

 

I have a staff manager (type) App and I want to sort the data by staff name. It would seem at the moment my sort function is sorting by the ID field which is not something we would search for. 

2021-04-27 06_40_53-Window.png The code my sort button is using is 

UpdateContext({SortDescending1: !SortDescending1})

I tried to change the above code thinking that ({SortDescending1: - related to column number, my name column is the second column in my SP List, so I tried changing that to ({SortDescending2: but that didn't work. 

 

I do already have some 'quick' filtering in place using a gallery as buttons

2021-04-27 06_50_42-Window.png

 

The code within my gallery is:

With(
    {WMST: 'NC MST Tracker'},
    Filter(
        WMST,
        StartsWith(
            'Employee Name',
            TextSearchBox1.Text
        ) && Switch(
            Gallery1.Selected.Value,
            "Mentor",
            Mentor,
            "AET",
            'AET Instructor',
            "MST",
            'MST Assessor',
            true
        )
    )
)

 

Any help much appreciated. 

1 ACCEPTED SOLUTION

Accepted Solutions
eka24
Super User III
Super User III

Your code on the sort order is ok. However you didn't include it on the code on the items property of the Gallery. So try this:

With( {WMST: 'NC MST Tracker'},
Sort(
Filter( WMST, StartsWith( 'Employee Name', TextSearchBox1.Text ) && Switch( Gallery1.Selected.Value, "Mentor", Mentor, "AET", 'AET Instructor', "MST", 'MST Assessor', true ) ) ,NameColumn,If(SortDescending1, Descending, Ascending)))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

1 REPLY 1
eka24
Super User III
Super User III

Your code on the sort order is ok. However you didn't include it on the code on the items property of the Gallery. So try this:

With( {WMST: 'NC MST Tracker'},
Sort(
Filter( WMST, StartsWith( 'Employee Name', TextSearchBox1.Text ) && Switch( Gallery1.Selected.Value, "Mentor", Mentor, "AET", 'AET Instructor', "MST", 'MST Assessor', true ) ) ,NameColumn,If(SortDescending1, Descending, Ascending)))

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

View solution in original post

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.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,366)