Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Average from 5 cells if not blank or zero

I need to calculate an average of 5 cells, but if a cell is blank or zero, it should neglect this value.

I am not able to get it to work with

=AVERAGEIFS(A10;B13;C5;D6;D8;"<>0")

Does anyone know the correct way to calculate this?

like image 217
Matthias Vanb Avatar asked Apr 01 '14 13:04

Matthias Vanb


People also ask

How do you find the average without zeros or blank cells?

=AVERAGEIF(A1:A11,"<>0") This formula eliminates zero values as a result of the criteria expression and Blank cells as default functionality of AVERAGEIF function, so it only counts cells in Excel average without zeros and average if not blank.

Does average if ignore blank cells?

Blank data values The AVERAGE, AVERAGEIF, and AVERAGEIFS function all automatically ignore blank cells (and cells that contain text values), so there is no need to provide criteria to filter out empty cells.

How do you calculate the average excluding certain cells in Excel?

To exclude outlying data from an average, you can use the TRIMMEAN function. This function excludes a specific percentage of data points from the top and bottom of the data set, then returns the average (mean) of the remaining data points.

How do you average cells based on criteria?

The Excel AVERAGEIF function calculates the average of numbers in a range that meet supplied criteria. AVERAGEIF criteria can include logical operators (>,<,<>,=) and wildcards (*,?) for partial matching. Get the average of numbers that meet criteria.


3 Answers

For an average of non-contiguous values, excluding any zeroes, try this formula

=IFERROR(SUM(A10;B13;C5;D6;D8)/((A10<>0)+(B13<>0)+(C5<>0)+(D6<>0)+(D8<>0));0)

or assuming no negative values you can use this

=IFERROR(SUM(A10;B13;C5;D6;D8)/INDEX(FREQUENCY((A10;B13;C5;D6;D8);0);2);0)

I used semi-colon delimiters as per question, change to commas if your regional settings demands

like image 99
barry houdini Avatar answered Sep 25 '22 10:09

barry houdini


You are looking for "Averageif": Excel showing averageif

Specifically, you want to use the range that includes possible blanks and then for the criteria use ">0"

=AVERAGEIF(C1:C5,">0")

Update: Non-contiguous ranges (not all working)

In the comments for this answer is a discussion about localization. My locale is United States (Excel 2010), so my delimiter between values passed to a function is the comma ,

Performing an averageif function on non-contiguous ranges is possible:

=AVERAGEIF(B1:B1:B3:B3:B5:B5:B7:B7,">0")

Excel 2010 comma-delimited averageif

For your locale, you might need to adjust delimiters, but the key thing is for the selection of individual cells, use the format "C1:C1:D4:D4" for the individual cells C1 and D4. The engine must be parsing the references as pairs.

like image 30
Wally Avatar answered Sep 23 '22 10:09

Wally


I found myself working on something that I wanted to compute a formula only with the cells that are not empty. To accomplish this, I used the following:

=IF(COUNT(DATA),COMPUTE(DATA),"")

(where COMPUTE is the formula or computation you want to make, and DATA is the selection of data you have--in my case a column of data).

To make sure the cells are empty/zero/something when not a "normal value" you can use something like: =IF(CONDITION,NORMAL VALUE,"")

Example:

=IF(SUM(DATA)=0,"",SUM(DATA))

This will only sum the data if it is non-zero, and other cells will see this cell as blank when the data is zero.

like image 22
Raj Avatar answered Sep 23 '22 10:09

Raj