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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (42,477)