这是一个公式,可以做你想要的。
细胞H6
:
=LET(LOSSES,COUNTIFS('SPREADS LOG'!$P:$P,"L",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<="&EDATE($A6,1)),WINS,COUNTIFS('SPREADS LOG'!$P:$P,"W",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1)),IF(AND(LOSSES=0,WINS=0),"",WINS))
细胞I6
:
=LET(LOSSES,COUNTIFS('SPREADS LOG'!$P:$P,"L",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<="&EDATE($A6,1)),WINS,COUNTIFS('SPREADS LOG'!$P:$P,"W",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1)),IF(AND(LOSSES=0,WINS=0),"",LOSSES))
使用空字符串而""
不是0
完美地从公式中排除单元格而不破坏它们。SUM
COUNTIFS
请注意,您不能使用其他单元格的值来决定是否填充0
值,因为这会创建循环引用。
没有的版本LET
:
细胞H6
:
=IF(AND(COUNTIFS('SPREADS LOG'!$P:$P,"L",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1))=0,COUNTIFS('SPREADS LOG'!$P:$P,"W",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1))=0),"",COUNTIFS('SPREADS LOG'!$P:$P,"W",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1)))
细胞I6
:
=IF(AND(COUNTIFS('SPREADS LOG'!$P:$P,"L",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1))=0,COUNTIFS('SPREADS LOG'!$P:$P,"W",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1))=0),"",COUNTIFS('SPREADS LOG'!$P:$P,"L",'SPREADS LOG'!$R:$R,">="&$A6,'SPREADS LOG'!$R:$R,"<"&EDATE($A6,1)))
这些公式假定您的列中的A
日期包含日期值(例如01.03.2021
三月)并使用自定义格式设置格式。这使您可以简单地复制整个列的公式,而无需手动更改日期。我强烈推荐这种方法,因为它对您当前的方法没有任何缺点,但是当您将其添加到您的自动化库中时,它可能具有巨大的优势。如果您决定坚持您的方法,则需要更改COUNTIFS
.
编辑是因为我误解了问题并提供了不正确的答案。