Return count of parent rows that contain specific data in child row
Hi all - this might be an easy one but I'm blanking. Here's a table:
The "2" being returned in row 13 uses: =COUNTIF([Primary Column]3:[Column2]11, "Green"). Easy enough.
I'm having trouble with rows 14 and 15. I'd like those to return a count of categories (i.e. parent rows) that contain a child with specific data. So, row 14 (green foods) should return a count of 1 since there is only one parent with one or more green foods. Row 15 (red foods) should return a count of 2 since there are two parents with children that have the color red.
Is there a simple function I'm missing here?
Thank you!!
Best Answer
-
Hey @browns99df,
I have an idea that is far from ideal but maybe it will help you.
Add a helper column with a formula that counts the descendants that are in your criteria, then COUNTIF this column without counting the '0', <>0.
Helper formula: =COUNTIF(DESCENDANTS([Column 2]1), "Green")
Main formula: =COUNTIF(Helper1:Helper9, <>0)
I am assuming other members will have better ideas for you but this works :)
Itai Perez
Project Manager | Transformation Department
Gong cha
If you found my comment helpful any reaction, Insightful, Awsome etc... would be appreciated🙂
Answers
-
Hey @browns99df,
I have an idea that is far from ideal but maybe it will help you.
Add a helper column with a formula that counts the descendants that are in your criteria, then COUNTIF this column without counting the '0', <>0.
Helper formula: =COUNTIF(DESCENDANTS([Column 2]1), "Green")
Main formula: =COUNTIF(Helper1:Helper9, <>0)
I am assuming other members will have better ideas for you but this works :)
Itai Perez
Project Manager | Transformation Department
Gong cha
If you found my comment helpful any reaction, Insightful, Awsome etc... would be appreciated🙂
Help Article Resources
Categories
Check out the Formula Handbook template!