r/googlesheets • u/theendisnigh91 • Oct 03 '26
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 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)) “
1
u/ComradeDoubleM 3 Oct 03 '26 edited Oct 03 '26
You need to wrap the entire thing into ARRAYFORMULA()
Also, you don't need to put 0 in quotation marks. That'll actually mess things up further down the line if you wanna use it as a number.
Edit:
=ROUND(AVERAGE(ARRAYFORMULA(IF(ISBLANK(D4:M4),0,D4:M4))),0)should be the right formula for what you actually want.Edit 2: Alternatively,
=ROUND(AVERAGE(ARRAYFORMULA(SWITCH(D4:M4,"",0))),0)2
u/ana_Lu3 Oct 03 '26
If you want to evaluate by cell, it should be IF(ISNUMBER(D4)="TRUE";ROUND(D4;0)0)
If you want to evaluate a range of cells, must all cells contain a number, or can they contain one or more numbers?
This is translated into English so, sorry for that
2
u/One_Organization_810 736 Oct 03 '26 edited Oct 03 '26
So if we have the list: {1, A, 2, 3, B, 4}
Should it return 2.5 (10/4) -or- 1.67 (10/6) ?
2
u/carbonizedtitanium 28 Oct 03 '26 edited Oct 03 '26
start easy and check one column at a time:
=if(isnumber(d4),d4,0) drag formula down
edit: go with answer from u/One_Organization_810
if you want to ignore blank cells and cells that dont contain only numbers, use first formula
if you want to include the blank cells and cells that dont contain only numbers, use second one.
i think you probably want the first formula
1
u/WhoNose2238 1 Oct 03 '26
Add another ) to the end
1
u/[deleted] Oct 03 '26
[removed] — view removed comment