web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I patch a looku...
Power Apps
Answered

How do I patch a lookup column with values from another single line column text in the same list?

(0) ShareShare
ReportReport
Posted on by 64

Introduction:

I exported a table (Contacts) from a web application to an Excel file (Contacts.xlsx). This table had a column called CompanyName that basically takes the company name from another table called Companies. There are about 400 contacts. Of course, some contacts belong to the same company. I also exported the content of the table Companies to an Excel file (Companies.xlsx). 

I wanted to recreate the same structure using Power Apps. So I first created a List called Companies based on Companies.xlsx file. Then I created another list called Contacts, based on the Contacts.xlsx file. Now the Contact List has a column called Title that has the company names. All good so far. So I created another column called CompanyName which of type Lookup that takes the company name from the Company List. Of course, this column in the Contacts list is empty. I could manually add the company name one by one. And I did that for about 50 names. There must be a smarter way to do it. All I want is to set the value of the CompanyName lookup column to the name in the Title column. But I have no idea how to go about it using PA. And help will be great. Thank you in advance. 

Color Guide: Table from a web database

Color Guide: Excel File

Color Guide: Sharepoint List

Color Guide: Column in a Sharepoint list. 

Categories:
  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @MrClick ,

    Do you want to update CompanyName field(lookup field) by using Title field(text field) and these two fields are belong to the same list Contact List ?

    If so, try this formula:

    ForAll(
     RenameColumns(
     Contact,"ID","ID1"
     ),
     Patch(Contact,LookUp(Contact,ID=ID1),
     {CompanyName:{Value:Title,Id:LookUp(Company,'company name'=Title,ID)}
     }
     )
    )

     

     

     

    Best regards,

  • MrClick Profile Picture
    64 on at

    Hi @v-yutliu-msft ,

     

    Thanks for the answer. Before I try it, I need to understand a few things.

    First, yes, CompanyName (which is a lookup field) and Title (text field) is in the same List. Basically, I want to copy the content of the Title text into my CompanyName.

     

    - Why did you use the RenameColumns function? Basically whatever in record one Title, I want to copy it to the value of CompanyName.

    - Why do you mean by this line below? Do you mean Contact instead of Company? 

    LookUp(Company,

     

    Thanks once again.

  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @MrClick ,

    Do you want to update Title field in Contact List by using CompanyName field in Contact List?

    If so, in your formula, you do not need to use any part about  Company list.

    What's more, the reason why I use RenameColumns function is that ForAll function and Patch function could not use for the same data source.

    If you use formula like this: 

    ForAll(
     Contact,
     Patch(Contact,...
    ))

    You will get error.

    To avoid this error, using RenameColumns is a good way.

    Have your tried this formula?

    ForAll(
     RenameColumns(
     Contact,"ID","ID1"
     ),
     Patch(Contact,LookUp(Contact,ID=ID1), //compare contact list with the renamed table
     {CompanyName:{Value:Title,Id:LookUp(Company,'company name'=Title,ID)}
     }
     )
    )

    I suggest you read this blog in details: https://powerapps.microsoft.com/en-us/blog/bulk-update-using-forall-and-patch/.

    Then you will know more about how to use the combination of ForAll and Patch function.

    I suggest you notice the RenameColumns part and [@] part.

     

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard