cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CMard63
New Member

How to use collection and copy and and records from another table

Hi

I have Table 1 and Table 2.

How can i copy records in column sum from table 2 to table 1 only if records in columns Proj and Konto match in Table 2 and 1.

I also want to add records to table 1 from table 2 if these records are missing in table 1.

The tables contain many records, so I guess you should use collections.

CMard63_0-1622786604104.png

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-jefferni
Community Support
Community Support

Hi @CMard63 ,

 

For the first question, try:

ForAll(Table2 As T2,Patch(Table1, LookUp(Table1, Proj = T2.Proj && Konto = T2.Konto), {Sum: T2.Sum}))

 

For the second question, try:

ForAll(Table2 As T2, 
       If(IsEmpty(LookUp(Table1, Proj = T2.Proj && Konto = T2.Konto)),
       Patch(
             Table1,
             Defaults(Table1),
             {Proj:T2.Proj,
              Konto: T2.Konto,
              Sum: T2.Sum
             }
       )
)

 

The two formulas are both using behavior functions so you will need to apply them OnSelect of buttons or OnVisible of screens.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Hi

Your solutions worked with a small adjustment in code for question 2.

I changed from "IsEmty" to "IsBlank" after that adjustment, everything worked.

Thanks!

 

 

View solution in original post

2 REPLIES 2
v-jefferni
Community Support
Community Support

Hi @CMard63 ,

 

For the first question, try:

ForAll(Table2 As T2,Patch(Table1, LookUp(Table1, Proj = T2.Proj && Konto = T2.Konto), {Sum: T2.Sum}))

 

For the second question, try:

ForAll(Table2 As T2, 
       If(IsEmpty(LookUp(Table1, Proj = T2.Proj && Konto = T2.Konto)),
       Patch(
             Table1,
             Defaults(Table1),
             {Proj:T2.Proj,
              Konto: T2.Konto,
              Sum: T2.Sum
             }
       )
)

 

The two formulas are both using behavior functions so you will need to apply them OnSelect of buttons or OnVisible of screens.

 

Hope this helps.

 

Best regards,

Community Support Team _ Jeffer Ni
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

Hi

Your solutions worked with a small adjustment in code for question 2.

I changed from "IsEmty" to "IsBlank" after that adjustment, everything worked.

Thanks!

 

 

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

secondImage

Power Apps Community Call

Please join us on Wednesday, October 20th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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 (1,505)