迭代SUMIF(?)

我有一个多天的数据集。每天的记录数不一样。我想对每天的余额进行求和,但是我希望在一天中的正记录数大于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公式?

linshumian999 回答:迭代SUMIF(?)

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

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

它可能看起来像: Table of Data

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

1 2 3

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

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

本文链接:https://www.f2er.com/3135290.html

大家都在问