cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
tmarch
Level: Powered On

Use sort, if and filter in one formula

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.

1 ACCEPTED SOLUTION

Accepted Solutions
tmarch
Level: Powered On

Re: Use sort, if and filter in one formula

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')

View solution in original post

6 REPLIES 6
Super User
Super User

Re: Use sort, if and filter in one formula

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
Level: Powered On

Re: Use sort, if and filter in one formula

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
Level: Powered On

Re: Use sort, if and filter in one formula

@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.
Super User
Super User

Re: Use sort, if and filter in one formula

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
Level: Powered On

Re: Use sort, if and filter in one formula

@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.
tmarch
Level: Powered On

Re: Use sort, if and filter in one formula

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')

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

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

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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