Forum Discussion

magic_trance's avatar
magic_trance
Copper Contributor
Jan 08, 2022

is it possible to calculate a weighted average (SUMPRODUCT) in a way that it ignores 0 and #DIV/0!?

Hello fellow Excel users,

 

I need to calculate a weighted average (SUMPRODUCT) but since one of the criteria has 0 value it shows the error #DIV/0! - the formula is not working. Is it possible to make the formula ignore both the 0 and #DIV/0! in the calculation?

 

Test
 (C) Quantity(D) Risk(E) Reward
Criteria 1790,27%15,82%
Criteria 2112,51%14,75%
Criteria 30#DIV/0!#DIV/0!
    
Weighted Average #DIV/0!#DIV/0!
Correct result 0,54828%15,68851%

Weighted Average (risk - column) has the following formula =SUMPRODUCT(C4:C6;D4:D6)/SUM(C4:C6)

 

I tried the two following formulas based on the research I did on the internet, but it also didn't work out:

=SUMPRODUCT(--(C4:C6>"0");--(D4:D6<>"#DIV/0!")/SOMASE(C4:C6;C4:C6>"0";C4:C6))

=SUMPRODUCT(--(C4:C6>"0");--(D4:D6<>"#DIV/0!")/SUM(C4:C6))

 

How can we fix it? Thanks for taking your time helping me.

 

 

Resources