cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sienna28
Level 8

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
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
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.
sienna28
Level 8

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.

 

 

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!
sienna28
Level 8

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
 
 
 
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});
)
);

sienna28
Level 8

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?

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

sienna28
Level 8

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

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,911)