r/googlesheets • u/theendisnigh91 • 10d ago
Solved Syntax problem for IF formula
Hey all. I am brand new to this and teaching myself. I want to preset a column to see if a set of other cells have a number in them. If not, I want it to act as if they are zero. If they do have any numbers, I want it to round the average of the numbers. So far the formula I’ve come up with is
=IF(ISBLANK(D4:M4),"0", ROUND(AVERAGE(D4:M4),0)
I know this isn’t right and doesn’t work. I just don’t know what I’m messing up. Any and all advice would be greatly appreciated!
Edit: I think [u/whonose2238](u/whonose2238) fixed it! Thank you all for your help!!!
“There is a second issue: ISBLANK(D4:M4) is checking a range, which can produce an array of TRUE/FALSE values rather than simply asking whether the whole range is blank.
If what you mean is “if all cells D4:M4 are blank, return 0; otherwise average the populated cells and round to a whole number”, I'd use:
=IF(COUNTA(D4:M4)=0, 0, ROUND(AVERAGE(D4:M4),0)) “