cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anapaolacw
Frequent Visitor

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
MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (7,124)