cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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
mdevaney
Super User III
Super User III

@Anonymous 

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
Pstork1
Dual Super User III
Dual Super User III

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.
RezaDorrani
Dual Super User II
Dual Super User II

@Anonymous 

 

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-collection/td-p/339716

 

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.

 

 

mdevaney
Super User III
Super User III

@Anonymous 

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,160)