Parent vs child flag
Hello,
I'm wondering whether it is possible or not to write a formula to indicate whether a certain cell is a parent or a child. The sheet I'm working with only has 2 levels, and I'd like to create a column that is able to delineate the two.
My initial thought is something along the lines of =IF([Cell 1] = CHILDREN(), 1, 0) but this obviously returns an Invalid Operation error.
Is a formula like this even possible?
Thanks!
Best Answers
-
I personally create a column and use the formula =COUNT(ANCESTORS())
This will return a 1 or 2 or 3 etc (based on what level it is) 1 = parent and so forth.
I then use conditional formatting to state if this newly created Column (Ancestor) has a 1, then highlight entire row blue.
If 2, then highlight light blue. --- I can then hide the column, and know light blue rows are my children rows.
- From There, if you wanted to use a Flag - you could enter a formula into a Flag Column
- =IF(Ancestors@row = 1, 1, 0) then it will check the flag if Ancestor is 1 (which is the parent)
-
I use a setup similar to @Angela Ryer where I count the Ancestors.
I also suggest this even if you only have the two levels. Here is an example of where counting child rows may not work...
Task A
Sub 1
Sub 2
Task B
Task C
Sub 3
Sub 4
In the above, Task B does not have any Child Rows, but it is still the same hierarchy as the other Task Rows. If you were to base it off of children vs no children, scenarios like this may skew things a bit for you.
If you used something along the lines of
=COUNT(ANCESTORS())
All Task Rows would have a 0 (zero) and all sub-task rows would be a 1.
Answers
-
I personally create a column and use the formula =COUNT(ANCESTORS())
This will return a 1 or 2 or 3 etc (based on what level it is) 1 = parent and so forth.
I then use conditional formatting to state if this newly created Column (Ancestor) has a 1, then highlight entire row blue.
If 2, then highlight light blue. --- I can then hide the column, and know light blue rows are my children rows.
- From There, if you wanted to use a Flag - you could enter a formula into a Flag Column
- =IF(Ancestors@row = 1, 1, 0) then it will check the flag if Ancestor is 1 (which is the parent)
-
I use a setup similar to @Angela Ryer where I count the Ancestors.
I also suggest this even if you only have the two levels. Here is an example of where counting child rows may not work...
Task A
Sub 1
Sub 2
Task B
Task C
Sub 3
Sub 4
In the above, Task B does not have any Child Rows, but it is still the same hierarchy as the other Task Rows. If you were to base it off of children vs no children, scenarios like this may skew things a bit for you.
If you used something along the lines of
=COUNT(ANCESTORS())
All Task Rows would have a 0 (zero) and all sub-task rows would be a 1.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!