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

How can I use ForAll and RemoveIf to remove items in one collection that are missing in another?

I have two collections I want to compare so I can ensure they match exactly. Here are samples of the two collections:

Collection1

IDItem
3C

 

Collection2

IDItem
1A
2B
3C


How can I write my ForAll( RemoveIf ) so it removes IDs 1 and 2 from Collection2 because they are missing from Collection1?

2 REPLIES 2

Hi @pwrappr01 ,

 

I dont't think you need the ForAll in this case. The RemoveIf already allows you to loop through a table.

 

Why not do?: 

RemoveIf(Collection2, Not(ID in Collection1.ID))

 

Resolver IV
Resolver IV

Hi @pwrappr01 !

 

You dont need to use ForAll since RemoveIf loops through all lines anyway. Try this formula:

RemoveIf(
    Collection2,
    CountRows(
        Filter(
            Collection1,
            Id = Collection2[@Id] && Item = Collection2[@Item]
        )
    ) < 1
)

BR

Pontus

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,164)