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 search and filter ...
Power Apps
Answered

Use search and filter combined

(0) ShareShare
ReportReport
Posted on by 1,085

Dear community,

I have a Gallery and a Searchbox and a Combobox 

The user can specify his search-criteria in the searchbox. The app will then search in all the columns of the table.

I would also give the user the ability to specify in which column to search by specifying the columnname in the combobox.

So it has to check of the user has select an item from the combobox. If so, then the search-criteria must be search in that column. If not then the search-criteria must be searched in all columns.

 

This is the code of the gallery:

 

 

If(
Len(searchQuery) > 0;
SortByColumns(
Search(
dbEmployeeDirectory;
searchQuery;
"crcfa_voornaam";
"crcfa_achternaam";
"crcfa_afdeling";
"crcfa_titel";
"crcfa_computer";
"crcfa_badgenummer";
"crcfa_gebruikersid"
);
"crcfa_achternaam";
If(
SortDescending1;
SortOrder.Descending;
SortOrder.Ascending
)
)
)

 

 

How can this be done? 

 

something like this:

If(!IsBlank(cbChoices.Selected.Value))
Search(
dbEmployeeDirectory;
searchQuery;
"crcfa_voornaam";
"crcfa_achternaam";
"crcfa_afdeling";
"crcfa_titel";
"crcfa_computer";
"crcfa_badgenummer";
"crcfa_gebruikersid"
);
If(cbChoices.Selected.Value)) = "Voornaam"
Search(
dbEmployeeDirectory;
searchQuery;
"crcfa_voornaam";
);

 

Gr. P

Categories:
  • Verified answer
    Ami K Profile Picture
    15,689 Super User 2024 Season 1 on at

    @PeKi72 - use:

     

    SortByColumns(
     With(
     {
     _searchAll: Search(
     dbEmployeeDirectory,
     searchQuery,
     "crcfa_voornaam",
     "crcfa_achternaam",
     "crcfa_afdeling",
     "crcfa_titel",
     "crcfa_computer",
     "crcfa_badgenummer",
     "crcfa_gebruikersid"
     )
     },
     With(
     {
     _searchVoornaam: Search(
     dbEmployeeDirectory,
     searchQuery,
     "crcfa_voornaam"
     )
     },
     If(
     cbChoices.Selected.Value = "Voornaam",
     _searchAll,
     _searchVoornaam
     )
     )
     ),
     "crcfa_achternaam",
     If(
     SortDescending1,
     SortOrder.Descending,
     SortOrder.Ascending
     )
    )

     

    The With function is useful in this scenario because it avoids having to repeat the same code more than once in the same expression.

     

    The With function is not a variable, but it does behave like local context variables. We can take the output of your Search query and apply it to a table I have called "_searchAll". We also take the output of your other Search query and apply that to another table I have called "_searchVoornaam".

     

    Now that we have our tables, we can then use the IF function to return the table we want to display based on a condition,

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 188 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 130

Last 30 days Overall leaderboard