# How do you tell a cell what to do based on being a Parent or Children row?

Options
✭✭✭✭
edited 06/17/22

I would like to use one formula in the entire column instead of having to copy and paste based on being a child or parent row. My child formula looks for word vacant in the name column and if so subtracts the total of 4 other cells from 0. If the word is not found the cell remains blank.

=IF(CONTAINS("vacant", Name@row), 0 - SUM([Career FTE - Active]@row:[Per Diem FTE - LOA]@row, ""))

The parent formula is just adding the children: =SUM(CHILDREN())

How do I put these together so that if it's a parent row it sums the children but if not it does the calculation? I'm confused on where to add the additional IF and CHILDREN in the formula. Any assistance is greatly appreciated!

Tags:

• ✭✭✭✭✭✭
Options

You would use an IF statement like so:

=IF(COUNT(CHILDREN(Name@row)) > 0, parent_formula, child_formula)

• ✭✭✭✭✭✭
Options

You would use an IF statement like so:

=IF(COUNT(CHILDREN(Name@row)) > 0, parent_formula, child_formula)

• ✭✭✭✭
Options

Thank you Paul! This worked perfectly and I never would have figured out the right order for this. Happy Friday!

• ✭✭✭✭✭✭
Options

Happy to help. 👍️

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!