Forum Discussion
liz123395
Apr 10, 2024Copper Contributor
How to nest IF statement with COUNTIF
Hi there, I am currently using =COUNTIFS(FY2:FY50, "<=13",FY2:FY50, ">=12") but I realized that I don't want the function to run if a number in another cell is less than 13 (the number in anothe...
liz123395
Apr 10, 2024Copper Contributor
Hi Hans,
would something like this work as well? =IF(AND(GJ4>3),COUNTIFS(FY2:FY50, "<=4",FY2:FY50, ">=3"), #N/A)
It seems to be working but I wanted to check in case it could create errors in the future
would something like this work as well? =IF(AND(GJ4>3),COUNTIFS(FY2:FY50, "<=4",FY2:FY50, ">=3"), #N/A)
It seems to be working but I wanted to check in case it could create errors in the future
HansVogelaar
Apr 11, 2024MVP
You mentioned GJ13 <13 earlier. The opposite of that would be GJ13>=13, not GJ13>3.
But it's up to you to decide which is correct.
There is no need to use AND here. AND(GJ4>3) is equivalent to GJ4>3.
To return the error value N/A#, use the function NA().
To return N/A# as text, use #N/A#".
So the formula could be
=IF(GJ4>3, COUNTIFS(FY2:FY50, "<=4",FY2:FY50, ">=3"), NA())
or
=IF(GJ4>3, COUNTIFS(FY2:FY50, "<=4",FY2:FY50, ">=3"), "#N/A")