# Nested IF with COUNTIF

Options
edited 12/09/19

I need to use a nested IF with COUNTIF.  Is that possible?  The scenario is that I need to count the number of “Red,” “Yellow,” and “Green” balls that are in a particular row in another sheet.  Then,

• If count of “Red”>=1, return “Red”
• If count of “Yellow”=1, return “Yellow”
• If count of “Green”=8 (or all), return “Green”

…in that hierarchy.

I have the individual COUNTIF statements as follows:

=IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Red") >= 1, "Red")

=IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Yellow") = 1, "Yellow")

=IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Green") = 8, "Green")

Can't seem to figure out how to nest them into one IF statement with the embedded COUNTIF statements.

Tags:

• ✭✭✭✭✭✭
Options

=IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Red") >= 1, "Red", IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Yellow") = 1, "Yellow", IF(COUNTIF({Copy of Compliance & Integration Detail Da Range 1}, "Green") = 8, "Green")))

Give this a go...

• Options

Thanks.  I'll give that a try.

• Options

Paul,

Thanks for the assist.  That syntax worked to a certain point.  I had to tweak it, and it works perfectly now.

=IF(COUNTIF({Compliance & Integration Detail Dashboard Range 1}, "Red") >= 1, "Red", IF(COUNTIF({Compliance & Integration Detail Dashboard Range 1}, "Yellow") >= 1, "Yellow", IF(COUNTIF({Compliance & Integration Detail Dashboard Range 1}, "Green") >= 8, "Green")))

## Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!