cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
222lovebirds
Helper I
Helper I

Creating a relationship between two tables

Hello,

I am new to Power App creation and have a problem merging two tables using a common column in order to display the supportive information to the end-users.

Main Info Table

222lovebirds_0-1637101698712.png

 

Supportive Info Table

table2format.png

I have a Main Info Table and Supportive Info Table. They are each in a separate excel sheet.

The Main Table is used to create a gallery on the startup page. By clicking an arrow on the gallery, it goes to a project profile details page. There, the selected item’s information is displayed from the Main Info Table.

 

In addition to data from the Main Info Table, I need to get people who are associated with the selected project from the Supportive Info Table and display their names and contact info in the red highlighted area below Project Team if there is a ‘Project_Number & project_number’ match between the Main Info Table and Supportive Info Table.

222lovebirds_2-1637101776026.png

222lovebirds_3-1637101795676.png

Any suggestions or help would be greatly appreciated.

Thanks,

222lovebirds

11 REPLIES 11
WarrenBelz
Super User
Super User

Hi @222lovebirds ,

If you put a label in the gallery which is (I assume based on 'Main Info Table' and Project_Number is the common linking field, then as an example, this in the Text will get you Role(#)

LookUp(
   'Supportive Info Table',
   Project_Number = ThisItem.Project_Number
)'Role(#)'

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

WarrenBelz
Super User
Super User

Hi @222lovebirds ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

222lovebirds
Helper I
Helper I

Hello, @WarrenBelz and thank you for your help. I am going to have to update the original question because the datasheet format has been changed. Please allow me about a week to update it. I appreciate your help and support!!

222lovebirds
Helper I
Helper I

Here is what I am trying now. I've added the code to 'App' - 'OnStart' to combine two tables and look up the match to display the project team members but all 'collection'(s) created in the code come back empty therefore I can't use them to display information on the app. What am I missing here? Are there better approaches to solve it?

ClearCollect(
ProjectCollection,
GroupBy(
MainInfoTable,
"Project_Name",
"Project_Number",
"ProjectInfoGrouped"
));
ClearCollect(
EmployeeCollection,
GroupBy(
SupportiveInfoTable,
"project_name",
"project_number",
"ProjectTeamGrouped"
));
ClearCollect(MasterCollection,AddColumns(ProjectCollection,"ProjectTeamGrouped",LookUp(EmployeeCollection, project_number=ProjectCollection[@Project_Number],ProjectTeamGrouped)));

------------------------------------------------------------------------------------------

Note: I am getting an 'Incompatible types in comparison' error message here. Just in case, if the error is about the column type, both project_number and Project_Number columns are set to 'Text' on tables...

Thank you for your help in advance!

Hi @222lovebirds ,

Firstly try this - also confirm that Project Number in both is a Single Line of Text.

With(
   {
      wProject:
      GroupBy(
         MainInfoTable,
         "Project_Name",
         "Project_Number",
         "ProjectInfoGrouped"
      ),
      wEmployee:
      RenameColumns(
         GroupBy(
            SupportiveInfoTable,
            "project_name",
            "project_number",
           "ProjectTeamGrouped"
         ),
         "project_number",
         "ProjectNumber"
      )
   },
   ClearCollect(
      MasterCollection,
      AddColumns(
         wProject,
         "ProjectTeamGrouped",
         LookUp(
            wEmployee, 
            ProjectNumber = Project_Number
         ).ProjectTeamGrouped
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

222lovebirds
Helper I
Helper I

Thank you, @WarrenBelz. The error message is gone 👍, but the MasterCollection comes back empty... Any suggestions?

222lovebirds_0-1638487361139.png

 

Hi @222lovebirds ,

It appears to be valid syntax for what you are doing - are you sure this filter produces records

LookUp(
   wEmployee, 
   ProjectNumber = Project_Number
)

and also how many records are there in each list?

222lovebirds
Helper I
Helper I

Hi @WarrenBelz. Thank you for your reply. I am not sure if this answers your question but here is what I see. Those grouped columns look empty. Also, the main table has 301 rows, and the supportive table has 286 rows. Thank you for your help!

222lovebirds_0-1638552575867.png

 

Hi @222lovebirds ,

The reason for the list numbers was that GroupBy will only work on up to your Delegation limit, but that is not an issue here. Also by your post

DoubleGroupBy.jpg

the tables are populated, so the collection worked in that respect - it has me baffled a bit why the other columns are empty - so for a bit of debugging, go back to the "long" way and see what is in the three collections.

ClearCollect(
   ProjectCollection,
   GroupBy(
      MainInfoTable,
      "Project_Name",
      "Project_Number",
      "ProjectInfoGrouped"
   )
);
ClearCollect(
   EmployeeCollection,
   GroupBy(
      RenameColumns(
         SupportiveInfoTable,
         "project_number",
         "ProjectNumber"
      ),
      "project_name",
      "ProjectNumber",
      "ProjectTeamGrouped"
   ),
);
ClearCollect(
   MasterCollection,
   AddColumns(
      ProjectCollection,
      "ProjectTeamGrouped",
      LookUp(
         EmployeeCollection, 
         ProjectNumber = Project_Number
      ).ProjectTeamGrouped
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (3,946)