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 : 9gh60NIUeTv25+5iQgKxno
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)

 

 

I have the same question (0)
  • RandyHayes Profile Picture
    76,291 Super User 2024 Season 1 on 30 Apr 2021 at 20:32:25
    Re: How to return multiple columns from a LookUp functin?

    @rprahalad 

    I am not entirely sure where a collection fits into this, but your formula will not work as you are trying to do equality operation on the ID and a table of ID's.  

     

    So are you trying to get all of the concatenated names based on a collection, or just how does this collection fit into your needs?

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on 30 Apr 2021 at 20:34:08
    Re: How to return multiple columns from a LookUp functin?

    @rprahalad 

    You need to concatenate the results of two lookup columns.  I don't think you can do it within a single lookup.

     

    LookUp(Employees,ID = colSearchResults[@ID].ID,FirstName) &" "& 
    LookUp(Employees,ID = colSearchResults[@ID].ID,LastName)

     

  • 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

  • RandyHayes Profile Picture
    76,291 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: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!

  • 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!

  • Verified answer
    RandyHayes Profile Picture
    76,291 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.

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

  • 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 

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 629 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 397 Super User 2025 Season 2

#3
wolenberg_ Profile Picture

wolenberg_ 232 Moderator

Last 30 days Overall leaderboard
Loading started