cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MaxDonen
Level: Powered On

Check if collection record exactly matches a selected item

I know this is simple, but...

 

The below 'exactin'  (or just 'in') statement works fine for checking whether the collection  'Col_GraphElement' contains a selected number within its ID_Number column. 

 

RemoveIf(Col_GraphElement,ID_Number exactin Col_GraphElement.ID_Number)

 

But if I replace 'exactin' with =, I get 'invalid argument type. 

 

This doesn't seem to make sense. How else can I check if the ID exactly matches an existing record in the collection? 

 

Thanks. 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Check if collection record exactly matches a selected item

Hi @MaxDonen ,

The reason why you should use 'exactin'  (or  'in') in the first formula is that:

Col_GraphElement.ID_Number represents a table, while ID_Number is a value.

You can not compare a value with a table.

You could only check whether a value is inside the table.

If you want to find the exactly record, you could try the formula:

LookUp(Col_GraphElement,ID_Number=selected.ID_Number)

ID_Number represent a field name inside Col_GraphElement table.

You could check whether a filed is equal to a value.

selected.ID_Number represent the selected number , you should replace it with a value.

 

Please note that when comparing you should use these two types

1)value in table

2)field name=value

 

 

Bets regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MaxDonen
Level: Powered On

Re: Check if collection record exactly matches a selected item

Ok thanks-that makes sense as far as a single value is concerned 🙂 The LookUp() function is ideal for this!

 

But what if multiple matches might be found? 

 

Eg:

Col_Fruit contains a column called Fruit_Name. Fruit_Name contains the following values:


"Orange"

"Apple"
"Apple"

"Apples"

"Pear"

 

Suppose I want to delete all 'Apple' entries. 

I cannot use the following:

 

 

RemoveIf(Col_Fruit,"Apple" in Col_Fruit.Fruit_Name)

 

 

This would remove "Apples" as well as the "Apple" entries. 

 

I cannot not use 'LookUp' here (as far as I can tell) since multiple records need to be removed.

 

I think that you explained a solution to this with the following. I just need to understand 2) a bit better. 

 

<blockquote>

Please note that when comparing you should use these two types

1)value in table

2)field name=value

</blockquote>

 

I think I understand 1). "Apple" in Col_Fruit.Fruit_Name would be an example of this. 

 

But I'm not sure I understand 2). Sorry if this sounds obvious, but how do I identify the field name in PowerApps? (Assuming field_name isn't a reserved keyword, of course)

 

Using the above example, the field name is whatever is contained for each record. So the field name of "Apple" is "Apple", etc...so the relevant syntax for 'field name = value' would be... "Apple" = "Apple"?

 

I think I just need some help clarifying this second point (point 2) but otherwise, thanks for the help so far. 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (3,235)