cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
07GT
Frequent Visitor

ForAll Patch Help

Hello,

 

Here's my scenario: I have a table (Table1) with a list of Asset Classes and their Costs, and a second table (Table2) which has a list of assets, and their class. I'd like to be able to patch the cost of the asset class from table 1 to all the corresponding assets in table 2.

 

Table1

Class_NameClass_Cost
Class A10
Class B20
Class C30

 

Table2

Asset_NameAsset_ClassAsset_Cost

AAA1

Class A?
AAA2Class A

?

BBB1Class B?
CCC1Class C?
CCC2Class C?
CCC3Class C?

 

My initial thought was to use the following:

 

Forall(Table2,    Patch(Table2, Lookup(Table1, Class_Name = Asset_Class, Class_Cost)   )

I figured out I can't use the same table in the forall and patch. Could someone help me out on the syntax here?

 

Any thoughts would be appreciated, thanks!

 

Jason

11 REPLIES 11
07GT
Frequent Visitor

@RandyHayes thanks for the update, I still get the same error, re expecting text and getting a table. 

 

@HenryARPhillips I did get your solution to work, however it didn't fill in all the lines. This may be a labelling issue on my end. I will try with a more concise number system for my Asset Class names instead of a text string and see if i can get them all to fill. 

 

You all may have assumed this already but the scenario I presented was just a simplified version of the actual scenario. In reality its a 1000+ list of assets broken down into ~70 general categories. 

 

Thanks for all your help folks, this place is a fantastic resource!

RandyHayes
Super User III
Super User III

@07GT 

The formula I provided:

Patch(Table2 As _item, 
    ForAll(
        Patch(_list, {Asset_Cost: Lookup(Table1, Class_Name = _item.Asset_Class, Class_Cost)})
    )
)

Should be working for you based on the original sample you provided.

If it is giving you an expected text and getting a table...where are you seeing that in the above formula?

Is Class_Cost as single text column?  How about Asset_Class...single text?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Top Solution Authors
Top Kudoed Authors
Users online (44,329)