cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper V
Helper V

How to get items where no match found in a collection

In my SharePoint list I have 2 columns
 
Title Title2
a     b
a     c
d     a
e     f
s     r
On my PowerApps form I have a text box called txtSearchTerm.Text
If I type in a text box the letter "a"
 
and create a collection to find any match in either of the columns
ClearCollect(Matches, Filter(DataSource,txtSearchTerm.Text in Title || txtSearchTerm.Text in Title2))
 
It returns all the matches with "a" in either colum.
a     b
a     c
d     a

But now I want to get the items where there was no match to "a".
So I would need
e     f
s     r
Preferably in a single column collection.
 
I cannot figure out how to do it & would appreciate any help.
 
Thank you
 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

Once you get it working you can just put the testCollection within a DISTINCT function.

ClearCollect(uniqueCollection,Distinct(testCollection, Value));

Please make sure to look back at my previous post as I have made some code changes.

View solution in original post

9 REPLIES 9
Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

Are you simply wanting the ID of the matching records in a single column called Value? Here’s my suggested approach to collect those IDs

Clear(testCollection);
ForAll(
your_datasource_name,
Collect(
testCollection,
{Value: If(Not(Or(TextInput1.Text in Title, TextInput1.Text in Title2)),ID)}
)
);

Please keep in mind this code must be put within a behaviour based property such as OnSelect, OnChange or OnVisible.
Highlighted
Helper V
Helper V

Re: How to get items where no match found in a collection

Thanks for the reply.

 

I am looking to get the values rather than an ID.

 

Reason being I will have to search through those values later.

 

 

Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

Can you please give a sample of what the data you would look like within a single column? Also, would you be open to collecting the whole record instead if a single column is not possible/too difficult? Let me know both please as well as your motivation for single column,

Thank you so much!
Highlighted
Helper V
Helper V

Re: How to get items where no match found in a collection

If the above sample is taken 

e     f
s     r
 
then it would become
 
e
f
s
r
 
hopefully in a single column of a new collection
 
Thanks
 
 
 
Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

Here, try this code. Hopefully I do not have any brackets out of place since I am writing this on iPhone.

Clear(testCollection);
ForAll(
your_datasource_name,
If(
Not(Or(TextInput1.Text in Title, TextInput1.Text in Title2)),
Collect(testCollection,{Value: Title});
Collect(testCollection,{Value:Title2});
)
);

Highlighted
Helper V
Helper V

Re: How to get items where no match found in a collection

Thanks I will try it out shortly.

 

Is there any quick way of ensuring only unique values are collected?

Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

Once you get it working you can just put the testCollection within a DISTINCT function.

ClearCollect(uniqueCollection,Distinct(testCollection, Value));

Please make sure to look back at my previous post as I have made some code changes.

View solution in original post

Highlighted
Helper V
Helper V

Re: How to get items where no match found in a collection

Thank you very much

 

At the end of this processing I want to perform a search command.

 

Is it possible to keep running the search until a match is not found?

I know there is no looping available in PowerApps.

I wonder if a timer could do it.

It would not matter if the whole procedure is run, but when a match is not found in the collection the timer should somehow end

Highlighted
Super User
Super User

Re: How to get items where no match found in a collection

@sienna28
It might be best to open up a new thread for this additional question. I don’t have much access to a computer right now (working on iPhone) so I can’t really test anything.

Did I answer you original question? If yes, please close the thread.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,210)