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

Creating collection from multiple tables

Hello, is it possible to create a collection based on different tables that are not related?

For example:

 

Table1 -> Names: "Person1", "Person2", "Person3"

Table2 -> Ages: "Age1", "Age2", "Age3"

 

And I want my collection to have a column for Table1 (Names) and a column for Table2 (Ages)

 

Names    |  Ages

_________________

Person1  |  Age1

Person2  |  Age2

Person2  |  Age3

 

The tables are not related, I just want to join them based on their position (the first name with the first age, second name with second age...)

Any ideas?

I can't seem to figure it out

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Creating collection from multiple tables

@anapaolacw 

PowerApps does not have the ability to join tables on based on the position.  I believe the technical term for your concept is a "Cartesian Join" and the resulting table is called a "Cartesian Product".  That's what I remember from learning SQL.

 

The only way to make your join is to edit the data and assign row numbers like so.

 

ClearCollect(
NamesTable,
{row: 1, name: "Person1"},
{row: 2, name: "Person2",
{row: 3, name: "Person3"}
);
ClearCollect(
AgesTable,
{row: 1, age: "Age1"},
{row: 2, age: "Age2",
{row: 3, age: "Age3"}
);

 

Then you would join the columns in another Collection like this

 

ClearCollect(
myJoinedTables,
ShowColumns(
AddColumns(NamesTable,"Age",LookUp(AgesTable,ID=NamesTable[@ID])),
"Name","Age"
)

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

3 REPLIES 3
Dual Super User
Dual Super User

Re: Creating collection from multiple tables

Not really possible without some kind of Field in common to relate one to the next.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Dual Super User
Dual Super User

Re: Creating collection from multiple tables

@anapaolacw 

 

Possible but with lots of work to link the 2 collections

 

Firstly you will need to ensure you have an index column on both the lists

Check below post on how to create index (look at the last response from MSFT)

https://powerusers.microsoft.com/t5/Building-PowerApps-Formerly/Patching-an-item-index-number-into-a...

 

Next what you would need to do is the following:

 

ForAll(CollectionTable, Collect(CollectionJoin,{Tables:CollectionTable[@Tables],Ages: Lookup(CollectionAges, Index = CollectionTable[@Index].Ages}))

 

where CollectionTable is name of you table colection with Index column

CollectionJoin is name of new collection

CollectionAges is name of collection with Ages and Index column

 

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

 

Super User
Super User

Re: Creating collection from multiple tables

@anapaolacw 

PowerApps does not have the ability to join tables on based on the position.  I believe the technical term for your concept is a "Cartesian Join" and the resulting table is called a "Cartesian Product".  That's what I remember from learning SQL.

 

The only way to make your join is to edit the data and assign row numbers like so.

 

ClearCollect(
NamesTable,
{row: 1, name: "Person1"},
{row: 2, name: "Person2",
{row: 3, name: "Person3"}
);
ClearCollect(
AgesTable,
{row: 1, age: "Age1"},
{row: 2, age: "Age2",
{row: 3, age: "Age3"}
);

 

Then you would join the columns in another Collection like this

 

ClearCollect(
myJoinedTables,
ShowColumns(
AddColumns(NamesTable,"Age",LookUp(AgesTable,ID=NamesTable[@ID])),
"Name","Age"
)

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

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