COUNTIF DESCENDANTS of the highest ancestor of the row being queried
Data sits at the third structural level of a data table.
I want a column with a value on each row to tell me how many descendants there are from the highest ancestor of that row (i.e. within that structure)
Basically, the current row is 1 of how many descendants?
So all third-level rows will show the same count value within the same structure
As an example, the value is returning correctly for each row when there's an absolute reference for the highest ancestor cell in that particular structure (Role$1348):
=COUNTIF(DESCENDANTS([Role]$1348), [Role]@row)
But I need each structure to know its own highest ancestor cell for the Role column - I don't want to be creating absolute refs for each structure.
Thanks
Best Answer
-
Hi TR,
There's likely a more succinct way to do this, but what I would do is have a helper column pulling in the Ancestor Names down one column, then use a COUNTIF function on that name column, like so:
My Parent Formula:
=IF(COUNT(ANCESTORS()) = 0, "Top Level", JOIN(ANCESTORS([Task Name]@row), ", "))
My Formula to count:
=COUNTIF(Parent:Parent, Parent@row)
Let me know if this is what you were looking to do or if I misunderstood!
Cheers,
Genevieve
Join us for Jumpstart 2025 with Community on 23 January (in two time zones)! 🎉 Register here.
Answers
-
Hi TR,
There's likely a more succinct way to do this, but what I would do is have a helper column pulling in the Ancestor Names down one column, then use a COUNTIF function on that name column, like so:
My Parent Formula:
=IF(COUNT(ANCESTORS()) = 0, "Top Level", JOIN(ANCESTORS([Task Name]@row), ", "))
My Formula to count:
=COUNTIF(Parent:Parent, Parent@row)
Let me know if this is what you were looking to do or if I misunderstood!
Cheers,
Genevieve
Join us for Jumpstart 2025 with Community on 23 January (in two time zones)! 🎉 Register here.
Help Article Resources
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.1K Get Help
- 443 Global Discussions
- 140 Industry Talk
- 472 Announcements
- 5K Ideas & Feature Requests
- 129 Brandfolder
- 150 Just for fun
- 71 Community Job Board
- 497 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 35 Webinars
- 7.3K Forum Archives
Check out the Formula Handbook template!