cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TJO
Resolver II
Resolver II

ForAll Patch Excel Table

Hi Folks

 

I'm trying to use the ForAll function to change records in a connected Excel table using the Patch function.

 

The idea is to go through each record (row) of the table, check for some conditions, and then change the record in question according if the conditions apply.

 

My formula looks like so:

 

ForAll(tabDaten, If(Werk = comboboxEingabeWerk.SelectedText.Value, Patch(tabDaten, Defaults(tabDaten), {Status : "Inaktiv"})))

 

 

For the Patch I get the error: "This function cannot operate on the same data source that is used in ForAll"

 

How should I change the Patch to refer to the current record in the loop?

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

HI @TJO 

See if the UpdateIf() function will work for you.  ref. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif .  Your Patch() function is flawed because you are using the Defaults() as the second element.  Defaults() when used in this fashion will try to create a new record.  See https://powerapps.microsoft.com/ru-ru/blog/bulk-update-using-forall-and-patch/  for the correct syntax to bulk patch your table. 

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

HI @TJO 

See if the UpdateIf() function will work for you.  ref. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-update-updateif .  Your Patch() function is flawed because you are using the Defaults() as the second element.  Defaults() when used in this fashion will try to create a new record.  See https://powerapps.microsoft.com/ru-ru/blog/bulk-update-using-forall-and-patch/  for the correct syntax to bulk patch your table. 

View solution in original post

@Drrickryp: Awesome, that did the trick 🙂

 

Updateif(tabDaten, Werk = comboboxEingabeWerk.SelectedText.Value, {Status: "Inaktiv"})

4e42b558fea53b8cd862f27c233b09c3.jpg

 

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,005)