web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How show number of chi...
Power Apps
Answered

How show number of children in parent gallery item

(0) ShareShare
ReportReport
Posted on by 704

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?

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    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 Profile Picture
    704 on at
    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.
  • Verified answer
    HansHeintz Profile Picture
    704 on at
    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)
     
  • smharrod Profile Picture
    33 on at

    @HansHeintz, thank you. Apart from having to replace your semi colon in your example with a comma, this worked great. I used it to hide the clickable icon in the parent gallery if there were no related child items in the related child gallery the icon linked to. So in the 'Visible' property of the icon I wanted to show if there were related child items, but hide if not, I added:

     

    If(
    !IsBlank(First(Filter(ToDoLine,Code=ThisItem.Code))),true
    )

     

    Where ToDoLine was the name of my child item SQL table and 'Code' was the related column name used for the relationship in both parent and child SQL tables.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard