+ Reply to Thread
Results 1 to 8 of 8

Finding how many child records for a given parent record

  1. #1
    Forum Contributor
    Join Date
    04-26-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2021
    Posts
    211

    Finding how many child records for a given parent record

    Hi everyone,

    In this table, I have 2 projects, CAPAs and Extensions. Extensions are child records of CAPAs.
    I need a formula in column Q that counts how many Extensions does each CAPA have, based on the ID column A. Column A has the parent IDs and child IDs. So in column Q, only CAPAs will have a corresponding number that it can be 0, 1, 2, etc, depending on how many child records belong to the CAPA.

    I attached the file as well.

    I hope I clearly explained what I need.

    Thank you guys

    CA.png
    Attached Files Attached Files
    Last edited by mq1973; 10-03-2017 at 09:59 AM.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Finding how many child records for a given parent record

    Hi,

    How do you relate an extension back to its parent CAPA? I can't see any connection there based on what you posted, and the ParentID column in the file is extremely confusing.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Finding how many child records for a given parent record

    xlnitwit is correct, it's hard to tell how you have the relationships stacked. If it's just sequential, then the following should work in Q2, filled down:

    =IFERROR(IF($P2="CAPA",MATCH($P2,$P3:$P$452,0)-1,""),"In Progress")
    Attached Files Attached Files
    If your problem has been solved, please use "Thread Tools" to mark the thread as "Solved".

    If you're grateful for this site's existence and would like to contribute to the community, please consider posting something hilarious in our joke thread:
    https://www.excelforum.com/the-water...ke-thread.html

  4. #4
    Forum Contributor
    Join Date
    04-26-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2021
    Posts
    211

    Re: Finding how many child records for a given parent record

    Sorry guys, my bad,

    I removed an important column in error
    Column A is the ID and column D is the parent ID . Please see the new attached file

    CA.png
    Attached Files Attached Files

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Finding how many child records for a given parent record

    You could use a formula like this
    =IF(P2="CAPA",COUNTIF(L:L,A2),"")
    though many of your parent IDs do not seem to exist in the file.

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Finding how many child records for a given parent record

    I think it's as simple as:
    =COUNTIF($D$2:$D$452,A2)

    ... unless I've missed something obvious

  7. #7
    Forum Expert
    Join Date
    05-20-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2016
    Posts
    2,103

    Re: Finding how many child records for a given parent record

    It looks like some of the CAPAs have parents, as well. Should those also be counted as children? If yes, try the following in H2 and fill down:

    =IF(G2="CAPA",COUNTIF($D$2:$D$452,$A2),"")

    This will count the occasions on which the CAPA's ID is listed in the "Parent ID" column.

    EDIT: Ha! I was the slowest to the COUNTIF party, so I'll include this addendum - to count only the "Extension" children, you can use:

    =IF(G2="CAPA",COUNTIFS($D$2:$D$452,$A2,$G$2:$G$452,"Extension"),"")
    Last edited by CAntosh; 10-03-2017 at 11:40 AM.

  8. #8
    Forum Contributor
    Join Date
    04-26-2012
    Location
    New Jersey
    MS-Off Ver
    Excel 2021
    Posts
    211

    Re: Finding how many child records for a given parent record

    Guys, thanks so much. I thought it was a lot more complicated.

    I just added a similar parent ID number for 3 extensions.

    CA solved.png
    Last edited by mq1973; 10-03-2017 at 11:57 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find the initial parent record based on the records in the last child records
    By Journeyman3000 in forum Access Tables & Databases
    Replies: 0
    Last Post: 03-30-2017, 08:46 PM
  2. [SOLVED] Sorting with Parent and Child
    By dominict in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-04-2013, 06:56 AM
  3. [SOLVED] Parent child relationships(working out parent item) for each item
    By grphillips in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-21-2013, 05:58 AM
  4. Parent Child Relationship
    By Automation Guru in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-02-2013, 04:48 AM
  5. Parent Child Macro
    By ckattookaran in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-06-2012, 11:50 AM
  6. [SOLVED] Sorting Parent Child
    By kcmtnbiker in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-30-2006, 09:00 PM
  7. parent - child schedules.
    By quimrider in forum Excel General
    Replies: 0
    Last Post: 12-14-2005, 02:52 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1