ABS() treats blanks as 0; is there a workaround for this?

TomCon

Active Member
Joined
Mar 31, 2011
Messages
373
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
If you put 5, blank, -10 in A1:A3 and then have this formula (blank is a clear cell empty of any content)
=AVERAGE(ABS(A1:A3))
you get answer 5, which is the average of ABS(5,-10,0)

Of course the "regular" AVERAGE function (without the ABS()) just averages the "present" values and does not treat the blank cell "as if it were value 0"

Is there a workaround for this so that i could have blank cells within a range for the formula AVERAGE(ABS()) and get a result of the Average of the "cells with values" and not treat empty cells as if they were value 0? I have tried IF statements that evaluate to "" or #N/A if the cell is empty but it also does not work. What a pernicious behavior!

If you can think of a workaround for this behavior of ABS() please let me know. Thank you.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Hi,

Not sure if I understand 100%, but how about putting ABS Outside AVERAGE:

Excel Formula:
=ABS(AVERAGE(A1:A3))
 
Upvote 0
How about
Excel Formula:
=AVERAGE(IF(A1:A3="","",ABS(A1:A3)))
 
Upvote 0
Solution
I suppose you could do this:
[ didn't pass all my tests ]
 
Upvote 0
With a (spill) helper.

Book1
ABCD
157.55
2FALSE
3-1010
Sheet1
Cell Formulas
RangeFormula
C1C1=AGGREGATE(1,2,D1:D3)
D1:D3D1=IF(NOT(ISBLANK(A1:A3)),ABS(A1:A3))
Dynamic array formulas.
 
Upvote 0
Yeah, I probably mis-understood OP.

@kweaver , briefly saw your answer in Post #4, think it would have worked, you just didn't include ABS:

Excel Formula:
=AVERAGE(IF(ISNUMBER(A1:A3),ABS(A1:A3)))

and for your Post #5, why not just this without the "helper":

Excel Formula:
=AVERAGE(IF(NOT(ISBLANK(A1:A3)),ABS(A1:A3)))

With these formulas including Fluff's in Post #3, for me, using 2016, I have to enter as CSE, but I think, since all of you have 365, including OP, it is entered normally (Not sure).
 
Upvote 0
How about
Excel Formula:
=AVERAGE(IF(A1:A3="","",ABS(A1:A3)))
Yes, that does it. Thank you! I cannot exactly work out in my mind why this works, doesn't the output vector also still have some spaces with "" in it that correspond to blanks in the input? Oh well, it works!!!!
 
Upvote 0
It's the Abs function that is turning the blanks into 0, so that formula only runs the Abs on those cells that are not ""
The Average function simply ignores the "" blank values.
I think, since all of you have 365, including OP, it is entered normally
That's right, no more CSE for us. :)
 
Upvote 0
Yeah, I probably mis-understood OP.

@kweaver , briefly saw your answer in Post #4, think it would have worked, you just didn't include ABS:

Excel Formula:
=AVERAGE(IF(ISNUMBER(A1:A3),ABS(A1:A3)))

and for your Post #5, why not just this without the "helper":

Excel Formula:
=AVERAGE(IF(NOT(ISBLANK(A1:A3)),ABS(A1:A3)))

With these formulas including Fluff's in Post #3, for me, using 2016, I have to enter as CSE, but I think, since all of you have 365, including OP, it is entered normally (Not sure).
Yes, thanks, this works too. Possibly a bit more intuitive. I guess the system will not let me mark two responses as "correct solution". But, thanks!
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top