Formula to ID indent level

I am trying to perfect a formula that I am currently using to make it a bit more robust.

Currently the formula I am using to ID indent level is:

=IF(COUNT(CHILDREN([Job Name]@row)) > 0, COUNT(ANCESTORS()) + 1)

This works until I end up with grandchild rows. Below is a screenshot of a sheet to better articulate what I am after.

Main reason for this is for sorting as currently when we sort by the primary column, the child/grandchild rows become a jumbled mess.

Answers

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!