cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Advocate I
Advocate I

Can I add fields from multiple data sources into a single gallery of items?

Hi,

 

I have recently started to build apps on my Android. I have 2 data sources.

 

1. Table 1{ID, Name, Date, Ticket Details}

2. Table 2 {ID, Name, Region}

 

I would like to be able to display items based on Region selected.  I am thinking to use Filter function on Table 1 by Region but I would need to somehow join the 2 tables by common field [Name] in order to be able to do so.

 

Any idea or help will be appreciated. Thank U!

 

Cheers

Boon Yar

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Re: Can I add fields from multiple data sources into a single gallery of items?

 

You need to simulate a join operation on the two tables. This can be done in multiple ways, for example via unique join keys or duplicate join keys. Are there any duplicates in your Name column? Depending on this, and whether you care about duplicates or not, try the following:

 

1. Join with duplicate Names

 

    gallery1.Items = AddColumns(Table1, "Region", LookUp(Table2, Name = Table1[@Name], Region))

 

2. Join with no duplicate Names (will produce nested data)

 

    gallery1.Items = AddColumns(

        GroupBy(Table1, "Name", "NameGroup"),

        "Group",

        AddColumns(NameGroup, "Region", LookUp(Table2, Name = NameGroup[@Name], Region)))

 

 

If you want to join on a different field, say "ID", use that field in either of the two inner lookups above (as in "ID = NameGroup[@ID]").

 

I hope this helps!

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

14 REPLIES 14
Highlighted
Continued Contributor
Continued Contributor

Re: Can I add fields from multiple data sources into a single gallery of items?

You can Collection feature for this purpose.

https://powerapps.microsoft.com/en-us/tutorials/function-clear-collect-clearcollect/

 

Use "Collect" function to get set of rows from Source1 and then again use "Collect" function to get rows from Source2. "Collect" function appends the records.

 

Hope this helps you.

Highlighted
Advocate I
Advocate I

Re: Can I add fields from multiple data sources into a single gallery of items?

Hi Perumal,

 

Thank you for your response.

 

Yes i did try collect. However, for my case, how can I apply collect to lookup fields and combine them into a single collection.. Just as stated in my example.

 

Thank you.

 

Cheers

Boon Yar

Highlighted
Power Apps
Power Apps

Re: Can I add fields from multiple data sources into a single gallery of items?

 

You need to simulate a join operation on the two tables. This can be done in multiple ways, for example via unique join keys or duplicate join keys. Are there any duplicates in your Name column? Depending on this, and whether you care about duplicates or not, try the following:

 

1. Join with duplicate Names

 

    gallery1.Items = AddColumns(Table1, "Region", LookUp(Table2, Name = Table1[@Name], Region))

 

2. Join with no duplicate Names (will produce nested data)

 

    gallery1.Items = AddColumns(

        GroupBy(Table1, "Name", "NameGroup"),

        "Group",

        AddColumns(NameGroup, "Region", LookUp(Table2, Name = NameGroup[@Name], Region)))

 

 

If you want to join on a different field, say "ID", use that field in either of the two inner lookups above (as in "ID = NameGroup[@ID]").

 

I hope this helps!

Radu Gruian [MSFT] ** PowerApps Staff

View solution in original post

Highlighted
Advocate I
Advocate I

Re: Can I add fields from multiple data sources into a single gallery of items?

Thanks Radu, I will try out method 1... currently PowerApps keeps hanging in my browser so I couldnt test that 😞

 

 

Will keep all posted

 

 

cheers!


Boon Yar

Highlighted
Advocate I
Advocate I

Re: Can I add fields from multiple data sources into a single gallery of items?

Hi Radu,

 

Yes tested Method1 ! Works.. thanks so much..

 

cheers

Boon Yar

Highlighted
Regular Visitor

Re: Can I add fields from multiple data sources into a single gallery of items?

@boonyar With the answers you found, I also got my app working with two sources, but my problem now is that the edit form doesn't work. Did you manage to do it for your app?

Highlighted
New Member

Re: Can I add fields from multiple data sources into a single gallery of items?

A couple of things.  First... Where are putting this code?  You guys always leave these important steps out.  Second, I have a SharePoint form based on a list, let's call it 'List 1'.  I want to set one of lIst 1's fields, well call it 'Field 2' , to a value looked up in List 2, based on a common Field (Field 1) in both lists.  

 

List.Field1 has the data I want to key on in List 2's field 1.   I want to set =Field2 to a value in List 2, based on a a value in List1.Field1 = List2.Field1.  

 

In SQL is would be  "Select Field2 from List1, where List1.Field1 = List2,Field1"

 

Any ideas on how I do this?

Highlighted
Advocate I
Advocate I

Re: Can I add fields from multiple data sources into a single gallery of items?

So Sorry... havent been logging in for a while. Yes edit form should work too. 

Highlighted
Anonymous
Not applicable

Re: Can I add fields from multiple data sources into a single gallery of items?

Hi @rgruian,,

 

I draw two tables with the following format.
I want to bring a value from another table according to the name of the item in the gallery that shows the data of the table A. comes but gives the following warning. How can I get rid of this warning? 
can we use this feature only in collections?


when I add a column with this method, the gallery1.selected formula does not work when I want to display the selected item in a display form. why what

Screenshot_1.png

 

Thank you

 

 

Helpful resources

Announcements
Ignite

Microsoft Ignite

This will be a conference that you do not want to miss!

secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (4,663)