I have an example google sheet (actual data I'm processing is sensitive).
I only want the number of people. (eg. X number of people have Red (but not Orange, Green, Blue).
Link to Google sheet so it's easier to understand and try formulas:
Any help is appreciated
Note: Added the below formulas to the Horanimal_copy_Sheet4 tab for easier viewing.
Step-by Step Instructions:
=UNIQUE($A$2:$A)
in cell D5
.=BYROW(D5:D,LAMBDA(r,IF(r="","",COUNTIF($A$2:$A,r))))
in cell E5
.=ARRAYFORMULA(IF(E5:E=1,XLOOKUP(D5:D,$A$2:$A,$B$2:$B,"",0,1),""))
in cell F5
.
This will return the only color associated with that person and nothing for the people with multiple colors.E2
) with =TRANSPOSE(UNIQUE($B$2:$B))
E3
enter =BYCOL(E2:2,LAMBDA(c,IF(c="","",COUNTIF($F$5:$F,c))))
This setup will work regardless of how many people you have or how many colors you have and will expand to accommodate any additions or contract for any removals automatically.
To recap... We go from raw list (which can continue to grow vertically):
To a list of all individuals, how many colors they're associated with, and if only associated with 1, which color that is (which can also continue to grow vertically and be any length):
To finally arrive at a count of how many times a color appears as the only color associated with a person: (which can expand horizontally as colors are added)
Expansion example:
When I add an entry for "Horanimal" and "Purple" at the end of cols A
& B
the tables automatically expand...
If I add another entry for Horanimal with a different color you'll see the count for Purple drops from 1 to 0 because there are no longer any people just in Purple:
Hope that helps!