cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
HansHeintz
Level 8

How show number of children in parent gallery item

I have asked sort of the same question earlier but a bit too complicated I am afraid.

So I try to make is as simple as possible.

Table: Parent(s)

Table: Child(ren)

In table Children a relation is defined many to one to table Parents.
Table Childrens now says there is a relation many to one, there is a lookup field Parent

Table Parents now says there is a relation one to many, relation is called Parent

In a gallery of parents I want to show the number of children a parent has

CountRows(Filter(Children;Parent=ThisItem.Parent))

Whatever I do it will not work. ThisItem.Parent is valid (shows as GUID in a label). In another gallery showing Children I have one Child with a valid Parent. ThisItem.Parent.Parent shows the right GUID

The identifiers are correct / not red underlined but there is a red line under "=" (invalid argument type)
In my case the names ot tables and fields are different but I wanted to make this as simple as possible.

Should this code work?

If so then some disambiguation is probably in order and I would like to know how I can disambiguate this statement as much as possible.

 

I also find that the code

First(Filter(Children;cra27_Parent.cra27_parentid=ThisItem.Parent)).Naam

insode will not work

But outside the gallery

First(Filter(Children;cra27_Parent.cra27_parentid=GalleryParents.Selected.Parent)).Naam

will work

The cra27_ bit is added by PA. My code was Parent.Parent (relation name.field name) Autodisambiguation?

1 ACCEPTED SOLUTION

Accepted Solutions
HansHeintz
Level 8

Re: How show number of children in parent gallery item

I found the right formula
Real table names are
DierLijst(en) (parent table)
DierLijstItem(s) (child table)
For example to know if a DierLijst in a gallery appears in DierLijstItems:
 
!IsBlank(First(Filter([@DierLijstItems];cra27_DierLijst.cra27_dierlijstid=ThisItem.DierLijst)))
the cra27 names are the "other" column names powerapps give to my own names
(To get to the number of detail lines just replace !isblank(first with the rowcount function)
 

View solution in original post

3 REPLIES 3
shailendra74
Level 10

Re: How show number of children in parent gallery item

Hi @HansHeintz 

 

If I understand your query correctly, you want to show the count of child records in the parent.

 

  1. In your masterlist gallery place a label and set the Text property to CountRows(childgallery.AllItems)
  2. Place a gallery (childgallery) inside parent gallery
  3. set the datasource as Filter(DetailsList, MasterID.Id = ThisItem.ID) // MasterID is lookup field in your child list ThisItem represents MasterList (parentgallery)

 

Gallery2 is Parent gallery

Gallery4 is Child gallery 

 

Screenshot 2019-08-07 at 8.06.05 AM.png

 

 

 

 

Screenshot 2019-08-07 at 8.08.29 AM.png

 

Thanks.

HansHeintz
Level 8

Re: How show number of children in parent gallery item

I was using the child count as an example of accessing the children through a parent item. I did not think there was a solution that just covers this but not other questions like accessing the properties of the first child. Also i was thinking of solutions in code and not adding another gallery. Thanks for your suggestion and i will give it a try and see what opportunities the extra gallery bring. Still i find it strange that filtering children based on on one parent while a relation between the two is defined is such a problem that no one can give a simple coded solution to it. I might just prefer to not work with pa relations at all and define and maintain my own relations by giving all my tables guid string fields. That way i don’t spent half the time develloping over silly problems like this.
HansHeintz
Level 8

Re: How show number of children in parent gallery item

I found the right formula
Real table names are
DierLijst(en) (parent table)
DierLijstItem(s) (child table)
For example to know if a DierLijst in a gallery appears in DierLijstItems:
 
!IsBlank(First(Filter([@DierLijstItems];cra27_DierLijst.cra27_dierlijstid=ThisItem.DierLijst)))
the cra27 names are the "other" column names powerapps give to my own names
(To get to the number of detail lines just replace !isblank(first with the rowcount function)
 

View solution in original post

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,908)