迭代SUMIF(?)

问题描述 投票:0回答:1

我有一个多日的数据集。每天的记录数不一样。我想对每天的余额进行求和,但是我希望在一天中的正记录数大于2中的负记录数时停止求和!

数据集(我只想解释一下,列Obs不在数据集上是:

Day  Situation   Result    Obs
01    POSITIVE    +1     will be add 
01    POSITIVE    +2     will be add
01    POSITIVE    +3     Will not be add, because there is already 2 Positive and 0 negative on this day
01    NEGATIVE    -4     Will not be add ...
02    NEGATIVE    -1     Will be add
02    POSITIVE    +2     add
02    POSITIVE    +1     add
02    POSITIVE    +3     add
02    POSITIVE    +5     Will not be add, because there is already 3 Positive and 1 negative on this day
03    POSITIVE    +1     add
03    NEGATIVE    -1     add
03    NEGATIVE    -2     add
03    NEGATIVE    -3     add
03    NEGATIVE    -4     add
03    POSITIVE     5     add
03    POSITIVE     6     add
03    POSITIVE     7     add
03    POSITIVE     8     add
03    POSITIVE     9     add
03    POSITIVE     10    will not be add, because there is already 6 positive and 4 negative

每天的总和为:第一天:+ 1 + 2 = + 3第02天:-1 + 2 + 1 + 3 = + 5第三天:1-1-2-3-4+5+6+7+8+9=+26

我如何使用EXCEL公式?

excel if-statement excel-formula sum sumifs
1个回答
0
投票

我将其设为用于处理数据动态结构的表。然后,我将在此表中添加一列,即“应计数”>

我将此公式添加到“应计数=COUNTIFS($B$2:$B2,"Positive",$A$2:$A2,A2)<=2] >>

它可能类似于:Table of Data

最后,我将添加一个具有唯一天数的新表。在这种情况下:

123

我将此公式添加到“天数”旁边的列:=SUMIFS(Table1[Result],Table1[Situation],"Positive",Table1[Day],G$2,Table1[Should Count],TRUE())

这应该给您一个表格,看起来像:Results

© www.soinside.com 2019 - 2024. All rights reserved.