cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Smudgers9
Helper III
Helper III

Filtering using 2 TextInput boxes

Looking for something quite simple but it seems to be escaping me.

I have 2 TextInput boxes and a Gallery.  Each TextInput box is separate to each other with a Search button linked to them.  One box searches phone numbers the 2nd searches postcodes.  
What I need is when a phone number is entered into the 1st box and the search button is pressed, the gallery will filter on that number if it exists in the datasource (Sharepoint list, Title column).
Or if a postcode is entered in the postcode box and that search button is pressed the gallery will filter based on that postcode.

I can get them working separately by using Filter('Datasource', varSite in Title) but unable to combine the 2 filters together so either can be used on the same gallery.  Any ideas?


1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Community Champion
Community Champion

@Smudgers9 

Here's how I would suggest combining the two textboxes.  Put this code in the Items property of the gallery.

Filter(
    your_datasource_name,
    TextInput_PhoneNumber.Text in PhoneNumberColumnName 
    Or TextInput_PostalCode.Text in PostalCodeColumnName
)

 

Note: I noticed you are using variables instead of references to the Text Inputs themselves.  You can replace the references where needed.


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Community Champion
Community Champion

@Smudgers9 

Here's how I would suggest combining the two textboxes.  Put this code in the Items property of the gallery.

Filter(
    your_datasource_name,
    TextInput_PhoneNumber.Text in PhoneNumberColumnName 
    Or TextInput_PostalCode.Text in PostalCodeColumnName
)

 

Note: I noticed you are using variables instead of references to the Text Inputs themselves.  You can replace the references where needed.


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Thanks for this, I'm sure I had tried this previously with no success. 

However, although this appears to work, I need the gallery to be blank when nothing is entered in either of these boxes, or if the variables are blank.  Normally I would use the below but any idea how I get this to work with both search boxes?  I thought of using the Visible attribute to hide the gallery if nothing is entered into these fields but not sure how to get this to work with 2 separate variables.

 

If(varNumber = "", Blank(),
Filter('BT-Sites', varNumber in Title Or varPostcode in Postcode))

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,400)