web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Use sort, if and filte...
Power Apps
Answered

Use sort, if and filter in one formula

(0) ShareShare
ReportReport
Posted on by 34

Is it possible to sort and filter a gallery with an if statement? There are two filters currently. One is for location, and that one filters the other one which is for Asset. I want the defualt of the gallery to show all items, but when the user selects the asset I want it to filter the items for that asset.

 

I have tried the following, but it errors out:

Sort(
If(Facility.Selected.Value="All"),
Machine_Projects,
Filter(
Machine_Projects,
Asset=Line.Selected.Value),
'Date Down')

 

HELP!!!! Thank you.

Categories:
I have the same question (0)
  • timl Profile Picture
    37,205 Super User 2026 Season 1 on at

    Hi @tmarch 

    You could try incorporating your If condition into your call to Filter like so:

     

    Sort(
     Filter(Machine_Projects,
     Facility.Selected.Value="All" || Asset=Line.Selected.Value
    ), 'Date Down'
    )
  • tmarch Profile Picture
    34 on at
    Thank you for your reply. Unless the user selects one of the filters, I want the gallery to show all items in the SP list. Using the solution you provided did not do that.
  • tmarch Profile Picture
    34 on at
    @timl Thank you for your reply. Unless the user selects one of the filters, I want the gallery to show all items in the SP list. Using the solution you provided did not do that.
  • timl Profile Picture
    37,205 Super User 2026 Season 1 on at

    Hi @tmarch 

    Could you confirm how the formula is not working? If the user does not select either of the filters, does your gallery show no records, or does it show more records than you expect?

    With none of the filters selected, can you add a label and set the text property to the following:

    (Facility.Selected.Value="All") 

    Can you confirm that this resolves to true?

  • tmarch Profile Picture
    34 on at
    @timl Yes, if the user does not select either filter nothing shows in the gallery. The label text shows "true" when "All" is selected; "false" when it is not selected.
  • Verified answer
    tmarch Profile Picture
    34 on at
    After trying a lot of different formulas etc, here is the workaround: I created a text input for Facility, and a text input for Asset. The Defaults were: "Facility.Selected.Value", and "Asset.Selected.Value". Then on the Gallery Items were: Sort( If( Facilityduplicate.Text="All", Machine_Projects, Filter( Machine_Projects, Asset=Assetduplicate.Text)),'Date Down')

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 387

#2
timl Profile Picture

timl 340 Super User 2026 Season 1

#3
Vish WR Profile Picture

Vish WR 301

Last 30 days Overall leaderboard