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

Lookup values from excel table and write to with patch

I have created a table that has 6 columns..

 

I want to search for a row in excel that meets two conditions.. then write to the column in that row..

 

I have used the following syntax

 

Patch(thelessonsbooked, LookUp(thelessonsbooked, learnernumber = thecgnum.Text && lessonnumber = feedbacknumber.Text), {learnernumber: thecgnum.Text, Completed: "SAD"});

 

thelessonbooked is the excel table

learnernumber is column1 a text field

feedbacknumber is column2 again a text field  and the data from these comes from selecting values in two linked gallaries. i.e the user click on a name and from that it lists a number of lessons that person attended.

 

So I want to write the word SAD in the column called "Completed"

 

if i do this it works but writes it to the first record with that learner number

 

Patch(thelessonsbooked, LookUp(thelessonsbooked, learnernumber = thecgnum.Text), {learnernumber: thecgnum.Text, Completed: "SAD"});

 

trouble is that learnernumber could have various lessons they are doing so I need to make sure it looksup the correct one.. although powerapps says the syntax is right it does not right anything to that cell on excel.

What am I doing wrong

1 ACCEPTED SOLUTION

Accepted Solutions

I created a work around by creating a unique field which I could reference rather than try and find two values and this works well.

View solution in original post

2 REPLIES 2
v-yutliu-msft
Community Support
Community Support

Hi @stefanlive ,

Could you describe more clearly about "learnernumber could have various lessons they are doing"?

I'm confused about your problem about the formula.

What's more, the reason why "if i do this it works but writes it to the first record with that learner number" is that:

LookUp function only returns the first record that meet the requirment.

If you want to update multiple records at the same time, you need to use ForAll function.

For example:

ClearCollect(collection1,Filter(thelessonsbooked, learnernumber = thecgnum.Text && lessonnumber = feedbacknumber.Text))
ForAll(collection1,Patch(thelessonsbooked, LookUp(thelessonsbooked,ID=collection1[@ID]),
{learnernumber: thecgnum.Text, Completed: "SAD"})
)

You could refer this:

https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I created a work around by creating a unique field which I could reference rather than try and find two values and this works well.

Helpful resources

Announcements
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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,002)