条件累加和作为数组公式 [英] Conditional cumulative sum as array-formula

查看:129
本文介绍了条件累加和作为数组公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列的值列出了结果列中的累计和。但是这需要针对第二列中的三个(排序)类别单独发生!
截图



请参阅示例工作表此处



我一直试图解决这个相当简单的问题,但没有成功。由于该公式将是已经非常广泛的数组公式的一部分,所以它是


  1. 必须是数组公式

    >

  2. 如果我们能够在没有进一步操作的情况下继续工作,那么最好的办法就是使用 = if() c> c> questioning


使用下拉公式解决这个问题非常简单,但由于某种原因我无法将其转换为数组公式。

= SUMIF($ B $ 2:B2,$ B $ 2:B2,$ A $ 2:A2)

解决方案

在共享电子表格中的工作表'JP'中,我输入了D2



(pre> = ArrayFormula((IF(LEN(A2:A),SUMIF(ROW(A2:A),<=& ROW(A2:A) :A),)))

看看是否可行?

编辑:对于每个类别的累计和,试试这个公式

  = ArrayFormula(if(len(B2 (B100),mmult {{mmult(if(B2:B100)A,0,转置(if(转置(行(B2:B100))> =行(B2:B100),(B2:B100 = A)*(A2:A100), 0))),行(B2:B100)^ 0),mmult(如果(B2:B100B,0,转置(if(转置(行(B2:B100))> =行:B100),(B2:B100 =B)*(A2:A100),0))),行(B2:B100) ,转置(如果(转置(行(B2:B100))> =行(B2:B100),(B2:B100 =C)*(A2:A100),0))),行(B2:B100 )^ 0)},{1; 1; 1}),))

公式分配到您分享的工作表。

I have one column with values of which I list the cumulative sum in the results-column. But this needs to happen separately for the three (sorted) categories in the second column! Screenshot

See the example sheet here.

I have been trying since hours to solve this rather simple problem without success. Since the formula will be part of an already pretty extensive array-formula it's

  1. Mandatory to be an array-formula

  2. Best if we can get it to work without further =if() questioning

It's very very simple to solve this with a drag-down formula but I can't translate this in to an array-formula for some reason!

=SUMIF($B$2:B2,$B$2:B2,$A$2:A2)

解决方案

In the sheet 'JP' in your shared spreadsheet, I entered in D2

=ArrayFormula((IF(LEN(A2:A), SUMIF(ROW(A2:A),"<="&ROW(A2:A),A2:A),)))

See if that works?

EDIT: for a cumulative sum per category, try this formula

=ArrayFormula(if(len(B2:B100), mmult({mmult(if(B2:B100<>"A", 0,transpose(if(transpose(row(B2:B100))>=row(B2:B100),(B2:B100="A")*(A2:A100), 0))), row(B2:B100)^0), mmult(if(B2:B100<>"B", 0,transpose(if(transpose(row(B2:B100))>=row(B2:B100), (B2:B100="B")*(A2:A100), 0))), row(B2:B100)^0) , mmult(if(B2:B100<>"C", 0,transpose(if(transpose(row(B2:B100))>=row(B2:B100), (B2:B100="C")*(A2:A100), 0))), row(B2:B100)^0)}, {1;1;1}),))

I also added this formula to the sheet you shared.

这篇关于条件累加和作为数组公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆