# Weighted average with embedded IF function

#### mcphea02

##### New Member
Hi,

I'm looking for a formula to determine a weighted average of productivity rates (tonnes/hour), weighted by their hours but only if the denominator is nonzero.

I have the tonnes in the vector A1:A10 and the hours in the vector B1:B10.

Thanks!

### Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

#### barry houdini

##### MrExcel MVP
Presumably the hours won't be zero when the tonnes has a value? In which case you can just divide total tonnes by total hours, i.e.

=SUM(A1:A10)/SUM(B1:B10)/24

Format as number

The above assumes that your "hours" are in time format, e.g. 30 hours is displayed as 30:00, rather than just 30. If display is as per the latter then remove /24 from formula

#### milesUK

##### Active Member
Calculate the tonnes/hour with

=IF(B1>0,A1/B1,0) placed in C1 and Fill down to C10. Calculate the average with

=AVERAGE(C1:C10) in C11.

#### mcphea02

##### New Member
Hi guys,

Thanks for the responses but I still haven't found what I'm looking for.

Barry; I agree, presumably the hours won't be zero when tonnes has a value however I need it to include an IF function so that the average isn't diluted with a bunch of zero productivity rates.

Miles; That would create a simple arithmetic average of the productivity rates, I'm looking for an average weighted by the hours. Also, I'm hoping to have a single formula which performs this function.

Hope you guys can help,

Regards.

##### MrExcel MVP
Hi guys,

Thanks for the responses but I still haven't found what I'm looking for.

Barry; I agree, presumably the hours won't be zero when tonnes has a value however I need it to include an IF function so that the average isn't diluted with a bunch of zero productivity rates.

Miles; That would create a simple arithmetic average of the productivity rates, I'm looking for an average weighted by the hours. Also, I'm hoping to have a single formula which performs this function.

Hope you guys can help,

Regards.
Care to provide a tiny sample along with the desired result?

1,106,516
Messages
5,511,759
Members
408,864
Latest member
cmajewsk

### This Week's Hot Topics

• Turn fraction around
Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
• TIme Clock record reformatting to ???
Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
• TextBox Match
hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
• Using Large function based on Multiple Criteria
Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
• Can you check my code please
Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
• Combining 2 pivot tables into 1 chart
Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...