cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Brianmaric
Helper IV
Helper IV

one to many relationships

How does power apps handle a one to many relationship?  For example, if you want to show a sales header and the related sales lines, how you do that?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User III
Dual Super User III

In the gallery that displays the parent record you will have some way to select an individual record.  You can then refer to that record elsewhere by the name of the gallery.selected.  So then the Items property of the child gallery is something like the following:

Filter(childsource, foreignkeycolumn = parentgallery.selected.keycolumn)


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

10 REPLIES 10
Pstork1
Dual Super User III
Dual Super User III

The way I've done this in the past is to put two galleries on a page.  The first gallery shows a list of the parent records and the second gallery shows a list of the child records for the selected parent.  A variation on this is to have one gallery for the parents on a screen and then a second screen that has a form on top and a gallery below.  When you select a parent on the main screen it navigates to the second detail screen and shows the selected parent in the form and the child records in the gallery.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Yes but how do you refer to the parent record?   You say 'selected',  how is that that field specified?  How does the app know how to link them?

Pstork1
Dual Super User III
Dual Super User III

In the gallery that displays the parent record you will have some way to select an individual record.  You can then refer to that record elsewhere by the name of the gallery.selected.  So then the Items property of the child gallery is something like the following:

Filter(childsource, foreignkeycolumn = parentgallery.selected.keycolumn)


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Yes, that looks correct.   But I can't seem to get it to work.  I tried doing a simple filter function using an input text box where the default is as follows:

Filter(Table1,TextInput1.Text = Title)

 

I get an error: 'Invalid argument type' and 'expected text value'

 

What am I doing wrong?

Thanks

Pstork1
Dual Super User III
Dual Super User III

Table1 is your Excel Table right and Title is one of the column names?  If so then switch the textbox and Title around.

Filter(Table1,Title = TextInput1.Text)


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Yes, table1 is an excel table.   and 'Title' (actually, it's 'SubTitle2'  is the name of the column on the Gallery (Gallery1) that I am trying to filter.  But I'm getting the same error when I switch it around. 

I am entering the filter formula in the input text box under the 'Default' property.

Also, I keep trying to accept your solution as the answer (I got the parent/child relationship working) but I keep getting a java script error.

More info: It says: "Change the rule to produce a {0} value.

 

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,140)