cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rprahalad
Helper V
Helper V

How to return multiple columns from a LookUp functin?

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)

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

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!

View solution in original post

RandyHayes
Super User
Super User

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

8 REPLIES 8
RandyHayes
Super User
Super User

@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?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Drrickryp
Super User
Super User

@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)

 

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
Super User
Super User

@rprahalad 

Is Employees the foreign (looked up) list?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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!

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!

RandyHayes
Super User
Super User

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
rprahalad
Helper V
Helper V

Thanks @RandyHayes ! That was it. 

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,128)