cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmchx
Helper IV
Helper IV

Sort and filter together

Dear Experts,

I'm very new to power app and

I stuck on sorting and filtering the status of the ticket status.

Sort(
    Filter(
        Requisition,
               _requestTypeFilter = Status.Value
            ),
            Created,
            Descending
)

I just want to filter all tickets by status and sort them by created date. And if I click on "All" button it needs to show all tickets.

On this code, it doesn't have any error but it doesn't work and I don't know why.

 

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @mmchx ,

What is the "All Button"? You can set a Variable on this button OnSelect

UpdateContext({varAll:true})

then your filter

Sort(
   Filter(
      Requisition,
      !varAll || _requestTypeFilter = Status.Value
   ),
   Created,
   Descending
)

and at Screen OnVisible

UpdateContext({varAll:false})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

mmchx
Helper IV
Helper IV

Oh I mean this button here. All these buttons, I created from the Gallery and set the On Select to 

Set(_requestTypeFilter, ThisItem.Filter)

mmchx_0-1627619746877.png

 

@mmchx ,

Then simply do this (disregard the Variable)

Sort(
   Filter(
      Requisition,
      _requestTypeFilter = "All" || _requestTypeFilter = Status.Value
   ),
   Created,
   Descending
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

mmchx
Helper IV
Helper IV

It seems not an error but my button doesn't work. Do I do something wrong?

I set OnSelect on the button gallery like this. This means when I click the "All" button, the _requestTypeFilter will equal to "All" right?

Set(_requestTypeFilter, ThisItem.Filter)

and on the "Request" Gallery, I set "Items" as you suggest. it won't work.

Actually, I saw the pattern to do all of these from the "Leave Request" template and adapt it on my own. Except my app doesn't has a manager view like "Leave Request"

Hi @mmchx ,

The code assumes that the variable _requestTypeFilter is set to All when you press the button and is a true/false argument - either it is equal to All (then do not filter) or it is something else and filter the list based on the Status equalling the value. Is this an accurate summary?

To test, but a label on the screen with the Text _requestTypeFilter and see it it equals All when you press this button.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,116)