cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TB05
Resolver I
Resolver I

Populate a collection with a ForALL and If condition

Hi, I'm trying to update/patch a new collection with records from an existing collection that DO NOT exist in a SharePoint list based on an ID and Date of the records. If the records exist in the SharePoint list I DO NOT want them added to my new collection.

Here is my "Patch" that I'm having issues with:


ClearCollect(collectEmployeeBonusDetails, Filter(ForAll(collectER_Dev_2 ,If(IsBlank(LookUp(BonusInputDEV, TimeID = ID And Date = DateRange)), ThisRecord))));

I also, get an error that DateRange is not a valid name, although it is in my collectER_Dev_2 collection.

TB05_0-1646663847147.png

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@TB05 

Please consider changing your Formula to the following:

ClearCollect(
    collectEmployeeBonusDetails, 
    Filter(collectER_Dev_2 As _item,
       !LookUp(BonusInputDEV, TimeID = _item.ID And Date = _item.DateRange, true)
    )
) 

In your original formula, you are referencing records (with ThisRecord) that are not what you expect.

There is no need for a ForAll - just the Filter is all you need.  Your original filter was not specifying any criteria either.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@TB05 

Please consider changing your Formula to the following:

ClearCollect(
    collectEmployeeBonusDetails, 
    Filter(collectER_Dev_2 As _item,
       !LookUp(BonusInputDEV, TimeID = _item.ID And Date = _item.DateRange, true)
    )
) 

In your original formula, you are referencing records (with ThisRecord) that are not what you expect.

There is no need for a ForAll - just the Filter is all you need.  Your original filter was not specifying any criteria either.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
TB05
Resolver I
Resolver I

Thank you @RandyHayes , you have helped me solve so many issues and quickly!  Very much appreciated!!!

I hope you have a great day.

RandyHayes
Super User
Super User

@TB05 

Happy to help!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,236)