Weighted Average

sparky2205

Well-known Member
Joined
Feb 6, 2013
Messages
507
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi folks,
I'm trying to calculate a weighted average for a set of data.
I've already used SUMPRODUCT successfully in another part of the spreadsheet but now my date is not in a continuous range so I'm struggling with it.
I have tried 2 approaches:

Attempt 1:
Breaking up the essence of the SUMPRODUCT formula into something like this:
=IF(G17=3,"N/A",((F7*C7)+(F10*C10)+(F13*C13))/(((C7*C7)+(C10*C10)+(C13*C13))/7.5))

Attempt 2:
Creating a separate list with links to the data so the data is in order and I can use SUMPRODUCT.
That creates its own issues. I'm having to use the VALUE function in order for SUMPRODUCT to return a value. Otherwise it returns 0.
The I'm having issues as it is possible to have N/A (text, not error) in the data which causes SUMPRODUCT to return #VALUE!

I'm posting my attempts here, there are a few so excuse the messy bits.

What I'm trying to achieve:
In G7 I want the weighted average of - F7, F10, F13 with the weights being in - C7, C10, C13 and the result expressed as a percent.

G7 currently relates to Attempt 1 above
R9 currently relates to Attempt 2 above

I appreciate any help.

Site Assessment Final.xlsx
ABCDEFGHIJKLMNOPQRSTUV
4Assessed By:UPDATE INFORMATIONWeightScoreWeightScore
5IF(G17=3,"N/A",((F7*C7)+(F10*C10)+(F13*C13))/(((C7*C7)+(C10*C10)+(C13*C13))/7.5))5N/A51
61Management / Quality Culture / Training (20)AssessmentWeightScoreSummarySection Score5100%51
71.1Quality Policy and Objectives (5)502N/A#VALUE!#VALUE!10100%51
81.1.1Quality PolicyN/AN/AN/A2#VALUE!#VALUE!71
91.1.2ObjectivesN/AN/AN/A0#VALUE!31
101.2Management Review (5)552100%125%
111.2.1Management Review Meeting531.50
121.2.2Management Review Action Items and Meeting Minutes5212.5#VALUE!
131.3Training (10)1062100%
141.3.1Quality System On Boarding531.50
151.3.2SME531.55
161.3.3Procedure training (Corp and Site)52120
171.3.4Manufacturing Training5211
Summary Sheet
Cell Formulas
RangeFormula
C4C4=MainSheet!C3:F3
C7,C10,C13C7=IF((LEN(B7)-LEN(SUBSTITUTE(B7,"(","")))>1,MID(B7,(FIND("~",SUBSTITUTE(B7,"(","~",2))+1),(FIND("~",SUBSTITUTE(B7,")","~",2))-FIND("~",SUBSTITUTE(B7,"(","~",2))-1)),MID(B7,FIND("(",B7)+1,(FIND(")",B7)-(FIND("(",B7)+1))))
D7,D10,D13D7=SUM(D8:D9)
E7,E10,E13E7=COUNTA(E8:E9)
F7,F10F7=IF(OR(D7=0,E7=F8),"N/A",SUMPRODUCT(D8:D9,E8:E9)/(SUMPRODUCT(D8:D9,D8:D9)/2))
C8:E9C8=MainSheet!H8
F8,F11F8=COUNTIF(E8:E9,"N/A")
F9,F12F9=SUM(E8:E9)
C11:E12C11=MainSheet!H13
F13F13=IF(OR(D13=0,E13=F14),"N/A",SUMPRODUCT(D14:D17,E14:E17)/(SUMPRODUCT(D14:D17,D14:D17)/2))
C14:E17C14=MainSheet!H18
F14F14=COUNTIF(E14:E17,"N/A")
F15F15=SUM(E14:E17)
S5S5=F7
S6S6=F10
S7S7=F13
I7I7=IF(G17=3,"N/A",((F7*C7)+(F10*C10)+(F13*C13))/(((C7*C7)+(C10*C10)+(C13*C13))/7.5))
I8I8=IF(G17=3,"N/A",((F7*C7)+(F10*C10)+(F13*C13))/(((C7*C7)+(C10*C10)+(C13*C13))/7.5))
R5R5=C7
R6R6=C10
R7R7=C13
R8R8=SUMPRODUCT(INT(R5:R7),INT(S5:S7))/20
R9R9=(SUMPRODUCT(VALUE(R5:R7)*(VALUE(S5:S7<>"N/A")))/((SUMPRODUCT(VALUE(R5:R7),VALUE(R5:R7)))/7.5))
V5V5=F34
V6V6=F37
V7V7=F43
V8V8=F49
V9V9=F53
U5U5=C34
U6U6=C37
U7U7=C43
U8U8=C49
U9U9=C53
U10U10=SUMPRODUCT(INT(U5:U9),INT(V5:V9))/20
S12S12=INT(S5)
G7G7=IF(G17=3,"N/A",((F7*C7)+(F10*C10)+(F13*C13))/(((C7*C7)+(C10*C10)+(C13*C13))/7.5))
G16G16=IF((LEN(B6)-LEN(SUBSTITUTE(B6,"(","")))>1,MID(B6,(FIND("~",SUBSTITUTE(B6,"(","~",2))+1),(FIND("~",SUBSTITUTE(B6,")","~",2))-FIND("~",SUBSTITUTE(B6,"(","~",2))-1)),MID(B6,FIND("(",B6)+1,(FIND(")",B6)-(FIND("(",B6)+1))))
G17G17=COUNTIF(F7,"N/A")+COUNTIF(F10,"N/A")+COUNTIF(F13,"N/A")
 
Beautiful John, works perfectly.
Thanks very much for your help.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Jon,
you pointed out in an earlier post: "Also, why are you multiplying the values in column C by themselves (squaring them) in the denominator of the formula in column G?"
I did this because it was the only way I could get the formula to work. But I don't understand why it is working when I construct it that way or now, in fact, if it is working correctly.
My understanding of how SUMPRODUCT works when the weights <> 100 is: =SUMPRODUCT(Range1:Range2)/Range1 where Range 1 are the weights.
However, in my case, the result must be expressed as a percentage and this isn't working. In my example below F61 contains my modified formula while H61 contains the "correct" formula.
As you can see F61 = 100%. H61 = 133%.
Also if I change the score in E62, i.e. reduce the overall score, H61 returns a higher score.
F61 does return a lower score, as expected, but I'm not sure it is still the correct score.
As the weightings that contribute to this score are: 2,2,2,1,2 I would be expecting a drop of 22% in the overall score in F61 i.e. (100/9)*2=22. But as you can see from F61 I am getting a drop of 24%.

I hope that's not too rambling Jon and that you have enough information to assist me again.
Please let me know if you need any clarifications.

Site Assessment Final Clean Short Version.xlsx
ABCDEFGH
564Facility (15)AssessmentWeightScoreSummarySection Score
574.1Overall Facility Appearance (6)   100%86%
584.1.1Outside1022 
594.1.2Inside1022
604.1.3Warehouse and material management1022
614.2Controlled Area(s) Manufacturing (9)   76%144%
624.2.1Appearance020 
634.2.2Cleanroom Environmental Controls1022
644.2.3Cleaning - Controlled Environment1022
654.2.4Cleaning - equipment1011
Summary Sheet
Cell Formulas
RangeFormula
C57,C61C57=IF((LEN(B57)-LEN(SUBSTITUTE(B57,"(","")))>1,MID(B57,(FIND("~",SUBSTITUTE(B57,"(","~",2))+1),(FIND("~",SUBSTITUTE(B57,")","~",2))-FIND("~",SUBSTITUTE(B57,"(","~",2))-1)),MID(B57,FIND("(",B57)+1,(FIND(")",B57)-(FIND("(",B57)+1))))
D57D57=SUM(D58:D60)
E57E57=COUNTA(E58:E60)
F57F57=IF(OR(D57=0,E57=F58),"N/A",SUMPRODUCT(D58:D60,E58:E60)/(SUMPRODUCT(D58:D60,D58:D60)))
C58:E60C58=MainSheet!H79
F58F58=COUNTIF(E58:E60,"N/A")
G57G57=(N(F57)*C57+N(F61)*C61)/(ISNUMBER(F57)*C57+ISNUMBER(F61)*C61)
D61D61=SUM(D62:D66)
E61E61=COUNTA(E62:E66)
F61F61=IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUMPRODUCT(D62:D66,D62:D66)))
C62:E65C62=MainSheet!H85
F62F62=COUNTIF(E62:E66,"N/A")
H61H61=IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUM(D62:D66)))
 
Upvote 0
Just to clarify, the weighted average is given by
Excel Formula:
=SUMPRODUCT(Range1,Range2)/SUM(Range1)
which is SUMPRODUCT divided by SUM, or
Excel Formula:
=SUMPRODUCT(Weights,Amounts)/SUM(Weights)

What looks funny is formulas like the one in F57, SUMPRODUCT divided by SUMPRODUCT:
Excel Formula:
=IF(OR(D57=0,E57=F58),"N/A",SUMPRODUCT(D58:D60,E58:E60)/(SUMPRODUCT(D58:D60,D58:D60)))

I think you want to use this instead, SUMPRODUCT divided by SUM:
Excel Formula:
=IF(OR(D57=0,E57=F58),"N/A",SUMPRODUCT(D58:D60,E58:E60)/(SUM(D58:D60)))
 
Upvote 0
Hi Jon, thanks for your time again.
What you're describing above is what I've done in post #12. I am recreating it below with the expected value of 100%.
If you look at F61 you will see I have used the "strange" formula: =IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUMPRODUCT(D62:D66,D62:D66)))
In H61 I have used what would conventionally be called the correct formula: =IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUM(D62:D66)))
i.e. =SUMPRODUCT(Weights,Amounts)/SUM(Weights)
But as you can see this doesn't evaluate properly.
Looking at the data below:
H61 should = 100% but instead I get 189% but I don't understand why.

Site Assessment Final Clean Short Version.xlsx
ABCDEFGH
564Facility (15)AssessmentWeightScoreSummarySection Score
574.1Overall Facility Appearance (6)   100%100%
584.1.1Outside1022 
594.1.2Inside1022
604.1.3Warehouse and material management1022
614.2Controlled Area(s) Manufacturing (9)   100%189%
624.2.1Appearance1022 
634.2.2Cleanroom Environmental Controls1022
644.2.3Cleaning - Controlled Environment1022
654.2.4Cleaning - equipment1011
664.2.5Gowning Area and Material Entry1022 
Summary Sheet
Cell Formulas
RangeFormula
C57,C61C57=IF((LEN(B57)-LEN(SUBSTITUTE(B57,"(","")))>1,MID(B57,(FIND("~",SUBSTITUTE(B57,"(","~",2))+1),(FIND("~",SUBSTITUTE(B57,")","~",2))-FIND("~",SUBSTITUTE(B57,"(","~",2))-1)),MID(B57,FIND("(",B57)+1,(FIND(")",B57)-(FIND("(",B57)+1))))
D57D57=SUM(D58:D60)
E57E57=COUNTA(E58:E60)
F57F57=IF(OR(D57=0,E57=F58),"N/A",SUMPRODUCT(D58:D60,E58:E60)/(SUMPRODUCT(D58:D60,D58:D60)))
C58:E60C58=MainSheet!H79
F58F58=COUNTIF(E58:E60,"N/A")
D61D61=SUM(D62:D66)
E61E61=COUNTA(E62:E66)
F61F61=IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUMPRODUCT(D62:D66,D62:D66)))
C62:E66C62=MainSheet!H85
F62F62=COUNTIF(E62:E66,"N/A")
H61H61=IF(OR(D61=0,E61=F62),"N/A",SUMPRODUCT(D62:D66,E62:E66)/(SUM(D62:D66)))
G57G57=(N(F57)*C57+N(F61)*C61)/(ISNUMBER(F57)*C57+ISNUMBER(F61)*C61)
G66G66=IF((LEN(B56)-LEN(SUBSTITUTE(B56,"(","")))>1,MID(B56,(FIND("~",SUBSTITUTE(B56,"(","~",2))+1),(FIND("~",SUBSTITUTE(B56,")","~",2))-FIND("~",SUBSTITUTE(B56,"(","~",2))-1)),MID(B56,FIND("(",B56)+1,(FIND(")",B56)-(FIND("(",B56)+1))))
 
Upvote 0
What is each percent value a percentage of? The maximum possible of each value? That's probably the issue. And maybe you should turn each value in column E into a percentage before doing the SUMPRODUCT.
 
Upvote 0
I got this sorted Jon. I'ts now in a condition I'm happy with.
Thanks again for all your help. A bit of learning/relearning for me as well.
I have only come across the N function once before and I had forgotten it.
Have a good weekend.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,194
Members
452,616
Latest member
intern444

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