是否可以在不添加辅助列的情况下对所有加权值求和?

huangapple go评论50阅读模式
英文:

Is it possible to sum all weighted values without adding helper columns?

问题

我已经设置了以下两个表格:

一个调查问题的表格

分组 问题 权重
G1 Q1 0.4
G1 Q2 0.3
G1 Q3 0.3
G2 Q4 0.5
G2 Q5 0.5
G3 Q6 0.8
G3 Q6 0.1
G3 Q7 0.1

实际上它有更多的问题,但这应该足够演示了。

此外,我还有一个包含所有答案和“受访者”(每个受访者回答关于N个受访对象的每个问题)的表格:

受访对象 问题 得分
S1 Q1 9
S1 Q2 8
S1 Q3 11
... ... ...
Sn Q7 4

现在... 我通常会在响应表(最后一个表格)中添加一个xlookup/index-match列,以获取每个权重,将其与得分相乘,然后从那里开始工作。

然而,我想知道是否有一种更优雅的解决方案,不需要这样做。

我想要的是有一个表格,它通过以下方式总结数据:

  1. 将每个问题与其权重相乘(使用某种查找)
  2. 按受访对象和分组分组(并求和值)
  3. 在以下表格中呈现:
X S1 S2 S3 ... Sn
G1 计算 计算 计算 计算 计算
G2 计算 计算 计算 计算 计算
G3 计算 计算 计算 计算 计算

最好使用一个公式。我认为通过使用filter函数、xlookup或类似的函数,这应该是可能的,但是我在我的尝试和搜索过程中都受阻了。

提前感谢您。

编辑:尝试了下面的方法。对于第1组中的问题,我得到了正确的值,但对于其他组却是0。我检查了在a、b、c、d中产生的矩阵,它们如下:

a:

是否可以在不添加辅助列的情况下对所有加权值求和?

b:

是否可以在不添加辅助列的情况下对所有加权值求和?

c:

是否可以在不添加辅助列的情况下对所有加权值求和?

d:

是否可以在不添加辅助列的情况下对所有加权值求和?

我相信问题出在SUM(IFERROR(d*c;0)),因为在这个例子中,c的前3行都是错误的,而d只在前3行中有值,所以它们将为0,当c达到其值时,d已经用完了。

示例工作簿链接:
工作簿

英文:

I have the following two tables set up:

A table of survey questions

Group Question Weight
G1 Q1 0.4
G1 Q2 0.3
G1 Q3 0.3
G2 Q4 0.5
G2 Q5 0.5
G3 Q6 0.8
G3 Q6 0.1
G3 Q7 0.1

In reality it has a lot more questions, but this should be enough for demonstration purposes.

In addition I have a table with all the answers and "subjects" (each respondent answers each question concerning N subjects):

Subject Question Score
S1 Q1 9
S1 Q2 8
S1 Q3 11
... ... ...
Sn Q7 4

Now.. what I would normally do is add an xlookup/index-match column to the response-table (last one) to pull each weight, multiply with the score, and then work from there.

I wonder, however, if there is a more elegant solution that does not require this.

What I want is to have a table that does summarizes the data by

  1. multiply each question by its weight (using some lookup)
  2. group by subject and group (and sum values)
  3. Present in following table:
X S1 S2 S3 ... Sn
G1 calc calc calc calc calc
G2 calc calc calc calc calc
G3 calc calc calc calc calc

Preferably in one formula. I think this should be possible by using the filter function, xlookup, or similar, but I have been stumped in both my own attempts and by my googling skills.

Thanks in advance..

Edit: Tried the below method. I get correct values for questions in group 1, but 0 for the others. I inspected the matrices produced in a, b, c, d there and they are as follows:

a:

是否可以在不添加辅助列的情况下对所有加权值求和?

b:

是否可以在不添加辅助列的情况下对所有加权值求和?

c:

是否可以在不添加辅助列的情况下对所有加权值求和?

d:

是否可以在不添加辅助列的情况下对所有加权值求和?

I believe the problem occurs in the SUM(IFERROR(d*c;0)), because in this example the first 3 rows of c are all errors, and the d only has values in the first 3 rows, so those will be 0, and when c gets to its values, d has run out.

Link to example workbook:
Workbook

答案1

得分: 2

如果我没弄错的话,这应该对你有用,使用<kbd>FILTER( )</kbd>函数。

是否可以在不添加辅助列的情况下对所有加权值求和?


• 单元格<kbd>J2</kbd>中使用的公式:

=LET(
     a,FILTER($B$2:$C$9,$A$2:$A$9=$I2),
     b,FILTER($F$2:$G$6,J$1=$E$2:$E$6),
     c,INDEX(TAKE(a,,-1),XMATCH(TAKE(b,,1),TAKE(a,,1))),
     d,INDEX(TAKE(b,,-1),XMATCH(TAKE(a,,1),TAKE(b,,1))),
     SUM(IFERROR(d*c,0)))

英文:

If i am not wrong this should work for you, using <kbd>FILTER( )</kbd> Function

是否可以在不添加辅助列的情况下对所有加权值求和?


• Formula used in cell <kbd>J2</kbd>

=LET(
     a,FILTER($B$2:$C$9,$A$2:$A$9=$I2),
     b,FILTER($F$2:$G$6,J$1=$E$2:$E$6),
     c,INDEX(TAKE(a,,-1),XMATCH(TAKE(b,,1),TAKE(a,,1))),
     d,INDEX(TAKE(b,,-1),XMATCH(TAKE(a,,1),TAKE(b,,1))),
     SUM(IFERROR(d*c,0)))

huangapple
  • 本文由 发表于 2023年7月31日 21:25:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76804092.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定