cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Tamras
Level 10

Sort / Filter Gallery items using buttons/icons

I have a gallery with the following Items property

SortByColumns(Filter(Routing, (InitiatorText = _varUser.Email) && oStatus = 1), "Title", Ascending)

Outside of this gallery, I added column headers with up/down arrows.  How do I re-sort the gallery items? I tried:

Sort(GalleryName.AllItems, Title, SortOrder.Descending)

Data Source: SharePoint Online list 

Same with filter if user wants to filter the gallery using different values. I can do this by creating multiple galleries but wondering if it can be done with one gallery?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Sort / Filter Gallery items using buttons/icons

Hi @Tamras 

 

I would have your Up/Down Arrows Set a variable, then SortbyColumns on that.

I am going to assume you mean you have only one up/down sort arrow, not one for each column, please let me know if that's not the case, as we can do that however it will take a bit more code.

 

So your Up Arrow's OnSelect would be:

Set(SortAscending, true)

 

And your Down Arrow's OnSelect would be:

Set(SortAscending, false)

 

Then your formula becomes:

SortByColumns(
Filter(
Routing,
(InitiatorText = _varUser.Email) && oStatus = 1),
"Title",
If(SortAscending,
Ascending,
Descending,
//This sets default sort Order
Ascending
)

)

This way, if your user selects one of the options, it will change the SortByColumn to Ascend/Descend depending on what you've chosen,

 

Any trouble with this, let me know,

 

Cheers,

ManCat




Don't forget to 'Mark as Solution' if a post answered your question and always 'Thumbs Up' the posts you like or helped you!

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Sort / Filter Gallery items using buttons/icons

Hi @Tamras 

 

I would have your Up/Down Arrows Set a variable, then SortbyColumns on that.

I am going to assume you mean you have only one up/down sort arrow, not one for each column, please let me know if that's not the case, as we can do that however it will take a bit more code.

 

So your Up Arrow's OnSelect would be:

Set(SortAscending, true)

 

And your Down Arrow's OnSelect would be:

Set(SortAscending, false)

 

Then your formula becomes:

SortByColumns(
Filter(
Routing,
(InitiatorText = _varUser.Email) && oStatus = 1),
"Title",
If(SortAscending,
Ascending,
Descending,
//This sets default sort Order
Ascending
)

)

This way, if your user selects one of the options, it will change the SortByColumn to Ascend/Descend depending on what you've chosen,

 

Any trouble with this, let me know,

 

Cheers,

ManCat




Don't forget to 'Mark as Solution' if a post answered your question and always 'Thumbs Up' the posts you like or helped you!

View solution in original post

Tamras
Level 10

Re: Sort / Filter Gallery items using buttons/icons

@iAm_ManCat  Thank you! It worked perfectly.

 

I set my variables on a button that navigates to the screen where below gallery is located

Set(_varSortBy, "Deadline"); Set(SortAscending, true);

Since I have multiple columns, I ended up with the following formula for my Gallery Items property:

SortByColumns(Filter(Routing, (InitiatorText = _varUser.Email) && oStatus = 1), _varSortBy, If(SortAscending, Ascending, Descending))

Above formula received delegation warning in _varSortBy so I just used nested if to work around it as I really only need 3 columns with sort option.

I added an icon on Title column with the following OnSelect property:

UpdateContext({SortAscending: !SortAscending, _varSortBy: "Title"})

Then changed the icon property to toggle between up/down:

If(SortAscending, Icon.ChevronDown, Icon.ChevronUp)

 

Helpful resources

Announcements
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,122)