cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
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
Highlighted
Super User III
Super User III

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. 

Highlighted
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

Highlighted

@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.

Highlighted

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.
Highlighted

Thank you! This worked perfectly. 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

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