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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Filter and Search a Ga...
Power Apps
Unanswered

Filter and Search a Gallery

(0) ShareShare
ReportReport
Posted on by

I am developing an app that will allow a user to search for a project in a Gallery using a text input box and to also filter by active projects using a checkbox. The data is stored in a sql database.

 

My filter code is not working a expected and I need some help combining the search and filter. The following filter code works when the checkbox is true. when the checkbox is false (unchecked) it returns nothing. The "Active" database field is a bit data type.

 

If(IsEmpty(Checkbox3.Value), '[dbo].[Project_Information]', Filter('[dbo].[Project_Information]', Checkbox3.Value, Active))

 

I would like to combine the filter code with the the following search code. Not sure how to do this.

 

If(IsBlank(TextInput2.Text), '[dbo].[Project_Information]', Search('[dbo].[Project_Information]', TextInput2.Text, "Project_Name", "Project_Number"))

 

Thanks in advance for any suggestions.

Categories:
I have the same question (0)
  • CarlosFigueira Profile Picture
    on at

    If you need to use two conditions (the checkbox - checked or unchecked - and the text input (blank or not), you can use a series of conditions in an If function like is shown below:

    If(
     !Checkbox3.Value && IsBlank(TextInput2.Text), '[dbo].[Project_Information]',
     IsBlank(TextInput2.Text), Filter('[dbo].[Project_Information]', Active),
     !Checkbox3.Value, Search('[dbo].[Project_Information]', TextInput2.Text, "Project_Name", "Project_Number")
     Search(Filter('[dbo].[Project_Information]', Active), TextInput2.Text, "Project_Name", "Project_Number"))

    - In the first line / condition (checkbox unchecked and text input blank), you would use the entire table

    - In the second line (text input blank), since you know that the checkbox cannot be unchecked (otherwise it would have matched the first condition), only perform the Active filter

    - In the third line, we already know that the text input is not blank (covered by the first two cases), so if the checkbox is unchecked, perform only the Search operation

    - Finally, if none of the above conditions were matched (e.g., the checkbox is checked and the text input is not blank), then perform both search and filter operations.

     

    You could possibly merge a couple of those lines, but I find that it makes it clearer what is being done this way.

     

    Hope this helps!

  • Community Power Platform Member Profile Picture
    on at

    Thanks Carlos,

     

    I have tried the code you provided but I get an error that the If statement has invalid arguments. Any help would be greatly appriciated.

  • Sparrow Profile Picture
    5 on at

    Missing a comma at the end of the 4th line:

     

    If(
     !Checkbox3.Value && IsBlank(TextInput2.Text), '[dbo].[Project_Information]',
     IsBlank(TextInput2.Text), Filter('[dbo].[Project_Information]', Active),
     !Checkbox3.Value, Search('[dbo].[Project_Information]', TextInput2.Text, "Project_Name", "Project_Number"),
     Search(Filter('[dbo].[Project_Information]', Active), TextInput2.Text, "Project_Name", "Project_Number"))

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard