cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stefanlive
Level: Powered On

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
stefanlive
Level: Powered On

Re: Lookup values from excel table and write to with patch

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
Community Support Team
Community Support Team

Re: Lookup values from excel table and write to with patch

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.
stefanlive
Level: Powered On

Re: Lookup values from excel table and write to with patch

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

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (5,117)