Showing results for 
Search instead for 
Did you mean: 
Advocate III
Advocate III

Search with the table result of other search

Hello, I was trying to do multiple search in one button, considering that if the search is not found it return all the records, this would be usefull for do a search with multiple parameters. For example in my case I have 2 parameters for search in the table, lets say:

parameter1, parameter2.

I want to do the next:


Search(Search('Data source'; String1.Text; Parameter1); String2.Text; Parameter2)


In theory I would get all the records that satisfy parameter1 = String1.Text && parameter2 = String2.Text, if doesnt satisfy parameter1 but it does in parameter2 I would get all the records that satisfy parameter2 but in my case I got nothing. It seems I cannot use the result of the first Search as parameter of the second one even though the result is a table with records (that acts the same as a Data source). As an alternative I am doing right now 2^2 = 4 "if" sentences but this isn't scalable at all because if I got 6 parameters I would get 2^6 = 64 "if" sentences, thats why I want to use the search function.


Is this a bug or I just don't understand well the functionality of search?


If you have any doubts about what I am trying to explain I would answer thankfully.




Accepted Solutions
Community Champion
Community Champion

PPS The caching will work only for sources with up to 500 rows.  If you have more than 500 lines then use this:


My solution is towards the end of the post

View solution in original post

Community Champion
Community Champion

Hi @Brank


Could you please clarify what Parameter1 and Parameter2 are?  Are they two different text fields in 'Data source'?


Assuming this is the case, what is the result you are looking for?
1) To satisfy parameter1 = String1.Text && parameter2 = String2.Text etc. etc.


2) To satisfy parameter1 = String1.Text || parameter2 = String2.Text etc. etc.


Finally, are you looking to match letter cases or not?




Hello @Meneghino,

Parameter1 and Parameter2 in this case are Columns in the table of the data source. As we know the "data source" can be an external data source (Common data service, SQL Server, etc) or tables. Lets say 'Data source' is an entity in the Common data service, this entity has the next columns:


Parameter 1                     l      Parameter2


Parameter value 1           l     Parameter value 2

Parameter value 3           l      Parameter value 4


Lets say I do: 

UpdateContext({firstSearch : Search('Data source'; "Parameter value"; Parameter 1) })  In this case the variable context "firstSearch" will have a table with all the records because in the parameter 1 I have 2 records that start with "Parameter value" then I want to do:


UpdateContext({secondSearch : Search(firstSearch; "Parameter value 4"; Parameter 2)}) In this case I will get in the variable context "secondSearch" a table with just the second record because Parameter 2 has "Parameter value 4". But in my case the secondSearch variable has an empty table.



Community Champion
Community Champion

Ok, I think I understand what you need.  For example:


Filter('Data source', String1.Text in Parameter1 || String2.Text in Parameter1, String3.Text in Parameter2 || String4.Text in Parameter2)

You can combine as you like and use 'exactin' instead of 'in' if you need to match case

Hi @Meneghino,

The problem is that Filter doesn't return all the records if one of the Strings.Text is blank, it would just don't return any records because it doesn't satisfy the condition.



Community Champion
Community Champion

Ok, you are right.  "" will return all records but a null value will not.

Use this for all the tests of the Filter:


(IsBlank(MySearchText) || MySearchText in TargetTextField)

Please let me know how you get on

I think you didn't undertand why I want to use Search instead of Filter. Smiley Surprised

If I used Filter I have to do 2^numberOfParameters Filters with If senteces for know if one of the parameters string is Blank or not because the Filter function will change in everycase.



Community Champion
Community Champion

OK, it works, so I think you must have something wrong in your syntax.  By the way, I would always avoid the use of spaces in column names. If you do have spaces, then you may need to wrap them in single quotes 'Parameter 1' etc.

Please note below that because you are in a different locale, you will need to substitute some , with ; and the ; with ;;


Here are the steps:

  1. Create Gallery1 with Items property as follows:
    Table({Parameter1: "Parameter value 1", Parameter2: "Parameter value 2"}, {Parameter1: "Parameter value 3", Parameter2: "Parameter value 4"})
  2. Create a button with OnSelect property as follows:
    UpdateContext({firstSearch : Search(Gallery1.AllItems, "Parameter value", "Parameter1") });
    UpdateContext({secondSearch : Search(firstSearch, "Parameter value 4", "Parameter2")})   
  3. Create a gallery with Items property as follows:

Please let me know how you get on.



I see what you did there!

I have no errors in syntax, the only difference between yours and mine is that I am doing the search with a data source using "Common Data Service", can you replace the in the first search the "Gallery1.AllItems" for data source in Common Data Service?.


Thanks in advance.



Community Champion
Community Champion

Hi @Brank, this may be a problem of delegation.


What you can try is to substitute this for the button OnSelect and eliminate Gallery1:

ClearCollect(CachedDataSource, 'Data source');
UpdateContext({firstSearch : Search(CachedDataSource, "Parameter value", "Parameter1") });
UpdateContext({secondSearch : Search(firstSearch, "Parameter value 4", "Parameter2")})   

Please let me know.


PS I use caching often also for perfomance purposes.  If the source does not change often you can just cache once after the user starts the app.  I do this by having a welcome screen and a "Proceed" button that caches all necessary tabels and then navigates to the first real screen of the app

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (5,597)