Parent child sum formula help

LinMyers
LinMyers ✭✭✭
edited 08/27/24 in Formulas and Functions

I need some assistance with a formula. The requirements are:

if a row is a parent, then sum the values of its child rows in column A

If the row is a child, ""

if the row is not a parent AND is not a child, then return the value in column A for that row.

I have tried numerous permutations, some of which get close, but none that work.

Answers

  • Samuel Mueller
    Samuel Mueller Overachievers
    edited 08/27/24

    I believe you will need a helper column, called "children" or whatever you want.

    in that column you will have a column formula, =count(children()), and you will use those results to determine if you are in a child row or a parent row

  • Corey W.
    Corey W. ✭✭✭✭

    I think this is does what you are looking for where cost represents your column A:

    =IF(COUNT(CHILDREN(cost@row)) > 0, SUM(CHILDREN(cost@row)), IF(COUNT(PARENT(cost@row)) > 0, "", cost@row))

    Your scenario doesn't mention what to do with the value in column A on the parent row when there are children. Is it to be included in the SUM as well?

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!