如何编写嵌套的 COUNTIF 公式?

发布于 2025-01-17 14:16:57 字数 484 浏览 4 评论 0原文

有一个用于检查日期的列A列B列B列用于10个人的退房日期(10行数据)。找到有多少人在不使用辅助柱的情况下住了5天。

我尝试的(不起作用)---

=COUNTIF(DATEDIF(A2:A11,B2:B11, "d"), ">5")

这给了我一个错误。有正确的方法吗?

如果我使用助手列,则C = netatedif(a2,b2,“ d”),然后do = countif(c2:c11,“> 5”)>它有效

,但是如何在没有助手列的情况下获得答案?

There is column A for check-in date, column B for check-out date for 10 individuals(10 rows of data). Find how many people stayed over 5 days WITHOUT using a helper column.

What I tried (doesn't work)---

=COUNTIF(DATEDIF(A2:A11,B2:B11, "d"), ">5")

This gave me an error. Is there a right way to do it?

If I use a helper column, C = DATEDIF(A2,B2,"d"), and then do =COUNTIF(C2:C11, ">5") it works

But how do I get the answer without the helper column?

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧夏天 2025-01-24 14:16:57

您可以尝试这样的方法,COUNTIF() 函数适用于范围,而 SUMPRODUCT() 函数适用于数组,因此最好使用后者,

FORMULA_SOLUTION

=SUMPRODUCT(--(($B$2:$B$11-$A$2:$A$11)>5))

帮助程序显示它提供相同的输出,

HELPER_SOLUTION

• 单元格C2 中使用的公式

=DATEDIF(A2,B2,"d")

并向下填充!

• 单元格 D2 中使用的公式

=COUNTIF($C$2:$C$11,">5")

FORMULA_SOLUTION

COUNTIF() 不接受数组常量(据我所知)。

• 单元格 A17 中使用的公式

=SUM(IF(B2:B10-A2:A10>7,1,""))

您还可以创建如下所示的 COUNTIF() 类型公式(组合 CTRL + SHIFT + ENTER):

• 单元格A15中使用的公式

=COUNT(IF(B2:B10-A2:A10>7,1,""))

注意:双重否定的使用 --> “双一元”,将 TRUE 或 FALSE 值强制转换为其等价数字 1 和 0。它用于需要数字进行特定数学运算的公式中。

You may try something like this, COUNTIF() Function works with a range, while SUMPRODUCT() Function with arrays, so its best to use the latter one,

FORMULA_SOLUTION

=SUMPRODUCT(--(($B$2:$B$11-$A$2:$A$11)>5))

With helper showing that it gives the same output,

HELPER_SOLUTION

• Formula used in cell C2

=DATEDIF(A2,B2,"d")

And Fill Down!

• Formula used in cell D2

=COUNTIF($C$2:$C$11,">5")

FORMULA_SOLUTION

COUNTIF() doesn't accept array constants (as far as I know).

• Formula used in cell A17

=SUM(IF(B2:B10-A2:A10>7,1,""))

You can also create a COUNTIF() type formula like this (the combination CTRL + SHIFT + ENTER):

• Formula used in cell A15

=COUNT(IF(B2:B10-A2:A10>7,1,""))

Note: The use of double negative --> "double unary" which coerces TRUE or FALSE values to their numeric equivalents, 1 and 0. It's used in formulas where numbers are needed for a particular math operation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文