cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tmarch
Frequent Visitor

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
Frequent Visitor

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
timl
Super User III
Super User III

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
Frequent Visitor

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
Frequent Visitor

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

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
Frequent Visitor

@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
Frequent Visitor

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (53,780)