cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
boonyar
Level: Powered On

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
PowerApps Staff rgruian
PowerApps Staff

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
13 REPLIES 13
Perumal
Level 10

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.

boonyar
Level: Powered On

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

PowerApps Staff rgruian
PowerApps Staff

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
boonyar
Level: Powered On

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 Smiley Sad

 

 

Will keep all posted

 

 

cheers!


Boon Yar

boonyar
Level: Powered On

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

DLazo_SQM
Level: Powered On

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?

dpual1031
Level: Power Up

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?

boonyar
Level: Powered On

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. 

bahardurmus
Level: Powered On

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
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 54 members 3,973 guests
Please welcome our newest community members: