简体   繁体   English

在Excel / Google表格中查找加权平均值

[英]Finding a weighted average in Excel / Google Sheets

I am trying to calculate student marks using a weighted average like in this sheet: 我正在尝试使用此表中的加权平均值来计算学生成绩:

https://docs.google.com/spreadsheets/d/1E35005CEgqYlkRYE3IIqVnWTaOROD54L3eEt4nIo-8Y/edit#gid=0 https://docs.google.com/spreadsheets/d/1E35005CEgqYlkRYE3IIqVnWTaOROD54L3eEt4nIo-8Y/edit#gid=0

B4:B13 has the equation to do it but I will have about 40 assignments which would made this long to type out. B4:B13有方程式可以完成,但我将进行大约40项分配,因此输入很长。

I tried using SUMPRODUCT but there are 2 problems: 1. the weights are in every other column 2. if the mark is a blank cell then the weight for that assignment should be zero. 我尝试使用SUMPRODUCT,但是有两个问题:1.权重在每隔一列中2.如果标记是空白单元格,则该分配的权重应为零。 (ex. see student 10 where assignment 1 weight should be zero and the overall grade should be 100%. (例如,参见学生10,其中作业1的权重应为零,而总成绩应为100%。

How can i use a formula to achieve this? 我如何使用公式来实现这一目标?

Try this: 尝试这个:

=ArrayFormula(SUM(IF((MOD(COLUMN($D4:$Z4),2)=0)*(N(+D$1:$Z$1)<>0)*($D4:$Z4<>""),$D4:$Z4*$D$2:$Z$2/$D$1:$Z$1)*100/SUM(IF((MOD(COLUMN($D4:$Z4),2)=0)*(N(+D$1:$Z$1)<>0)*($D4:$Z4<>""),$D$2:$Z$2))))

在此处输入图片说明

If you want a formula that will grow with extra columns added then use this monster: 如果您想要一个公式,该公式将增加额外的列,那么请使用此怪物:

=ArrayFormula(SUM(IF((MOD(COLUMN($D4:INDEX(4:4,MATCH(1E+99,$2:$2))),2)=0)*(N(+D$1:INDEX($1:$1,MATCH(1E+99,$2:$2)))<>0)*($D4:INDEX(4:4,MATCH(1E+99,$2:$2))<>""),$D4:INDEX(4:4,MATCH(1E+99,$2:$2))*$D$2:INDEX($2:$2,MATCH(1E+99,$2:$2))/$D$1:INDEX($1:$1,MATCH(1E+99,$2:$2)))*100/SUM(IF((MOD(COLUMN($D4:INDEX(4:4,MATCH(1E+99,$2:$2))),2)=0)*(N(+D$1:INDEX($1:$1,MATCH(1E+99,$2:$2)))<>0)*($D4:INDEX(4:4,MATCH(1E+99,$2:$2))<>""),$D$2:INDEX($2:$2,MATCH(1E+99,$2:$2))))))

It will find the last column in which there is a number in row 2 and use that as its ending column. 它将找到第二行中有一个数字的最后一列,并将其用作结尾列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM