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

Community site session details

Session Id : laZy0O5K4YE0AFgyUud1u7
Power Apps - Building Power Apps
Answered

How to return multiple columns from a LookUp functin?

Like (0) ShareShare
ReportReport
Posted on 30 Apr 2021 20:26:11 by 377

Hello All,

 

I need to do a LookUp on a table and return a concatenated return value o two columns.  Can you please let me know how to do it?

 

I tried this and its giving me an error. Here clSearchResults is another collection that has the ID column. That part is not an issue but returning multiple fields in a concatenated form is giving me an error. Thanks 

 

LookUp (Employees,

ID = colSearchResults[@ID].ID,

FirstName & LastName)

 

 

  • Kornel Profile Picture
    50 on 24 Nov 2023 at 09:06:15
    Re: How to return multiple columns from a LookUp functin?

    Hi @Vannieljevla 

    I did not found better solution.

    What I am doing now is doing two step process.

    1. First I create the lookup (as you did, but in my case I pull all columns):

    ClearCollect(
     colPeopleMaster,
     AddColumns(
     colPeople,
     "personLookup", LookUp('People Details', GPN = colPeople[@sap_coo_gpn])
    ))

    2. I pick columns that I am interested (as example I put two, but in my case there are 8 of them):

    ClearCollect(
     colPeopleMasterManagement,
     AddColumns(
     colPeopleMaster,
     "name", personLookup.name,
     "email", personLookup.email
    ))

    Hope that helps,

    Kornel

  • Vannieljevla Profile Picture
    53 on 02 Nov 2023 at 16:38:23
    Re: How to return multiple columns from a LookUp functin?

    Hi @Kornel. Did you find a solution for this? I am running into the same problem.

     

    I found that you can retrieve the data with one LookUp using the following code, however it means you need to refer to it everytime as SearchData.name, instead of just having a column named "name".

    ClearCollect(
     colPeopleMaster,
     AddColumns(
     colPeople,
     "SearchData",
     LookUp('People Details', GPN = colPeople[@sap_coo_gpn],
     {
     name: Name,
     email: Email
     }
     )
     )
    )

    Please let me know if there is a cleaner approach!

  • Kornel Profile Picture
    50 on 03 Aug 2023 at 07:22:29
    Re: How to return multiple columns from a LookUp functin?

    So more like using join in SQL than vlookup in Excel.

    Join two tables with a key.

  • Kornel Profile Picture
    50 on 26 Jul 2023 at 09:05:48
    Re: How to return multiple columns from a LookUp functin?

    Hi all,

    I am thinking about similar situation, but I need separate columns.

    Right now the code looks like:

    ClearCollect(
     colPeopleMaster,
     AddColumns(
     colPeople,
     "name", LookUp('People Details', GPN = colPeople[@sap_coo_gpn], Name),
     "email", LookUp('People Details', GPN = colPeople[@sap_coo_gpn], Email)
    ))

    I have some collections where I need to pull 5-7 different columns, is there a way to do it in one LookUp?

    Thanks!

    Kornel 

  • rprahalad Profile Picture
    377 on 30 Apr 2021 at 20:55:47
    Re: How to return multiple columns from a LookUp functin?

    Thanks @RandyHayes ! That was it. 

  • Verified answer
    RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 30 Apr 2021 at 20:44:40
    Re: How to return multiple columns from a LookUp functin?

    @rprahalad 

    You don't need to make two calls to the datasource.  In fact, that is not how it works at all in PowerApps.  When you lookup against a datasource, there is one call made to your cloud session table.  After that, the app has the value for the future.

     

        LookUp(Employees, ID = 5, FirstName & "  " & LastName)

    Will return the First and last names combined together for the Employees record with an ID of 5 in this example.

     

    So, your original formula is fine.  Your problem is that you are trying to lookup on an ID and a Table of ID's, that will not work.

  • Verified answer
    rprahalad Profile Picture
    377 on 30 Apr 2021 at 20:41:08
    Re: How to return multiple columns from a LookUp functin?

    Yep! Sorry I should have mentioned this. This code is actually part of AddColumns block. It is one-one and I am just querying the Employees table with an absolute scalar ID and i need to return just a concatenated name. Thanks again!

  • rprahalad Profile Picture
    377 on 30 Apr 2021 at 20:36:56
    Re: How to return multiple columns from a LookUp functin?

    That's what I feared. Making two calls to DataVerse just to get  data from two columns  is what I am trying to avoid. Thanks for your response though!

  • RandyHayes Profile Picture
    76,287 Super User 2024 Season 1 on 30 Apr 2021 at 20:35:31
    Re: How to return multiple columns from a LookUp functin?

    @rprahalad 

    Is Employees the foreign (looked up) list?

  • rprahalad Profile Picture
    377 on 30 Apr 2021 at 20:34:25
    Re: How to return multiple columns from a LookUp functin?

    Thanks for your response. Its actually a LookUp column. So, technically  I am just doing Select * from Employees where ID= 5. But I just need to do Select FirstName + " " + LastName from Employees where ID=5

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 2