简体   繁体   English

优秀。 如何在新行中对每个组的某些条件求和?

[英]excel. how to sum certain criteria per group on new row?

I have a raw data set right now that is set up in columns like so: 我现在有一个原始数据集,该数据集按如下所示设置:

Group1  Cost 1  Amount
Group1  Cost 2  Amount
Group1  Cost 3  Amount
Group1  Cost 4  Amount
Group2  Cost 1  Amount
Group2  Cost 2  Amount
Group2  Cost 3  Amount
Group2  Cost 4  Amount
Group3  Cost 1  Amount
Group3  Cost 2  Amount

I want to (I'm guessing this requires a macro) sum the amounts for costs 2&3 on a new row for each group. 我想(我猜想这需要一个宏)将每个组的新行2&3的金额相加。 The group & cost columns are just titles.Is this possible? 组和成本列只是标题。这可能吗?

Ignore the first highlighted field. 忽略第一个突出显示的字段。 I kind of tried to show what I wanted to do, with two groups. 我有点试图通过两个小组展示我想做的事情。 I need to sum the light blue line items for each group. 我需要对每个组的浅蓝色订单项进行汇总。 The groups being the 1111111 column. 组是1111111列。 http://i.stack.imgur.com/D2vj3.png http://i.stack.imgur.com/D2vj3.png

I would put this in whatever cell you want the sum to be in and do =SUM(Cost2+Cost3). 我会将其放在您希望总和位于的任何单元格中,然后执行= SUM(Cost2 + Cost3)。 So for example lets say Group1 Cost2 is in C3 and Group1 Cost3 is in C4 the formula would be =SUM(C3+C4) 因此,例如,假设Group1 Cost2在C3中,而Group1 Cost3在C4中,则公式为=SUM(C3+C4)

use this formula: 使用以下公式:

=SUMPRODUCT(N(A:A="Group1"),N(B:B="Cost 2"),C:C)+SUMPRODUCT(N(A:A="Group1"),N(B:B="Cost 3"),C:C) = SUMPRODUCT(N(A:A =“ Group1”),N(B:B =“ Cost 2”),C:C)+ SUMPRODUCT(N(A:A =“ Group1”),N(B:B = “费用3”),C:C)

But after entering the formula you should press ctrl-alt-enter not "enter" directly 但是输入公式后,您应该按ctrl-alt-enter而不是直接“输入”

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

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