cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
v-yutliu-msft
Community Support
Community Support

Hi @Anonymous ,

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.
Anonymous
Not applicable

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,923)