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

Filter Two Tables Based on ID

Hello everyone! I'm new to PowerApps and want to first say thanks for the wealth of knowledge shared in these forums.

 

I've setup an app using several tables, as a simple example:

 

Table1: ID, Student, Grade

Table2: ID, Math, Reading


The app gallery uses data from Table1. After choosing a gallery item, I would like to populate a "Label" where the text is a "score" from Table2 based on the selected gallery item. I'm not sure where to begin with this and I haven't been able to find any solutions to similar questions that worked for this situation. 

 

Thanks in advance for the support.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @loepan ,

How do you set up the relationship between the two Tables? Through ID column?

 

If you want to retrieve corresponding info from another table from one table, you must make sure you have set up a relationship between the two tables through column value.

 

I assume that the two Tables owns common ID column value, they are related through the ID column. Based on the needs that you mentioned, I think the LookUp function could achieve your needs.

Add a Label in your app, set the Text property to following (retrieve Math score):

LookUp(Table2, ID = Gallery1.Selected.ID, Math)

or

LookUp(Table2, ID = Gallery1.Selected.ID).Math

 

If you want to retrieve the Reading score from the Table2, please try the following formula:

LookUp(Table2, ID = Gallery1.Selected.ID, Reading)

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Drrickryp
Super User II
Super User II

Hi @loepan 

What you are describing is a classic many to many relationship. It requires three tables to model it. The third table is called a junction table. 

v-xida-msft
Community Support
Community Support

Hi @loepan ,

How do you set up the relationship between the two Tables? Through ID column?

 

If you want to retrieve corresponding info from another table from one table, you must make sure you have set up a relationship between the two tables through column value.

 

I assume that the two Tables owns common ID column value, they are related through the ID column. Based on the needs that you mentioned, I think the LookUp function could achieve your needs.

Add a Label in your app, set the Text property to following (retrieve Math score):

LookUp(Table2, ID = Gallery1.Selected.ID, Math)

or

LookUp(Table2, ID = Gallery1.Selected.ID).Math

 

If you want to retrieve the Reading score from the Table2, please try the following formula:

LookUp(Table2, ID = Gallery1.Selected.ID, Reading)

 

Best regards, 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-xida-msft 

Thanks for the response. This is really helpful. I have not setup a relationship between the two tables. Both tables are located in Excel Files in OneDrive for Business. What is the best move forward for setting up a relationship between these two tables? Should I move the data to a CDS or is there is way to do it through Excel? If a CDS, can you recommend a guide that's beginner friendly?

 

Thanks again.

Hi @loepan ,

If the ID column in your Table1 represents the Student ID, you could consider add a column in your Table2 called "studentID" to reference values from the ID column in your Table1 (you need to enter the value in studentID column manually). Then this relationship would be set up. After that, you could use above solution I provided in your scenario.

 

In addition, you could consider create two SP Lists as your data source. Then within SP List2, you could defined a LookUp type column to reference values from the ID column in your SP List1.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you! This worked perfectly. 

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 (2,364)