cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
boonyar
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
rgruian
Power Apps
Power Apps

 

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

15 REPLIES 15
Perumal
Continued Contributor
Continued Contributor

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.

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

rgruian
Power Apps
Power Apps

 

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

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

Hi Radu,

 

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

 

cheers

Boon Yar

Anonymous
Not applicable

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

Anonymous
Not applicable

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?

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

Anonymous
Not applicable

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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,167)