如果语句为false,则零

发布于 2025-01-22 19:43:21 字数 565 浏览 1 评论 0 原文

这是Google表中的一些示例数据:

我想返回clice of the the the pack的总和,如果一列包含拾音器,并且在这种情况下(在这种情况下)列中的所有文本都是实际的)。

这是我尝试过的公式:在这种情况下(“拾取”总和为0,它将其返回为false,但我需要它为$ 0.00)

=IF(
  SUMIFS(C1:C5,B1:B5,"Pick Up"),
  SUMIFS(C1:C5,B1:B5,"Pick Up"),
  SUMIFS(C1:C5,B1:B5,"Actuals")
)

Here is some sample data in a Google Sheet:

https://docs.google.com/spreadsheets/d/1cIP118xPmNxMVv0vlpxZ7igp5pVr000f0H8RRILCQIw/edit#gid=0

I would like to return the sum of Pick Up if a column contains Pick Up, and the sum of Actuals if it doesn't (in that case all texts in the column would be Actuals).

Here is the formula I have tried: In this case when the ( "Pick up" Sum range is all 0, it returns it as False but I need it to be $0.00)

=IF(
  SUMIFS(C1:C5,B1:B5,"Pick Up"),
  SUMIFS(C1:C5,B1:B5,"Pick Up"),
  SUMIFS(C1:C5,B1:B5,"Actuals")
)

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

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

发布评论

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

评论(1

地狱即天堂 2025-01-29 19:43:23

看看这张Google表:

您想让您的病情使您的病情成为Countifs :

=IF(
  COUNTIFS(B1:B5, "Pick Up")>1, 
  SUMIFS(C1:C5, B1:B5, "Pick Up"), 
  SUMIFS(C1:C5, B1:B5, "Actuals")
)

实际上,实际上第二个选项中的sumifs并不是真正必要的。如果列中唯一的事情是实际的,那么您可以使用总和:

=IF(
  COUNTIFS(B1:B5, "Pick Up")>1, 
  SUMIFS(C1:C5, B1:B5, "Pick Up"), 
  SUM(C1:C5)
)

希望这会有所帮助。


原始答案如下。我在示例数据后对他们进行了编辑,并提供了有关问题的清晰度。它们是出于历史目的,或者有人在问题上查看编辑历史记录,或者是否不接受编辑。

编辑:根据评论中的反馈。如果您想在没有取货时返回实际的总和,请将SUMIFS条件更改为Countifs:

=IF(
  COUNTIFS(X97:X126,$D97:$D126,"Pick Up") > 0,
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

原始答案:

如果没有一些实际数据,这有点困难,但是我认为您的问题是,如果您的条件(Sumifs使用”拾取”)返回0,然后是一个虚假的值,因此将转到第二个输出。

=IF(
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

试试看:这样:

=IF(
  SUMIFS(X97:X126,$D97:$D126,"Pick Up") >= 0,
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

如果Sumifs返回0(或更高),那么您将获得一个明确的真实值,可以在IF的第一部分中使用,而不是Excel将尝试将其解释为布尔值的数字。

Take a look at this Google Sheet:

https://docs.google.com/spreadsheets/d/13a4ZcgFu-yRiyZohXmh0aDnW0EheTOGElXvyQ0WHeHI/edit#gid=0

You want to make your condition a COUNTIFS, so that if Pick Up is found in the column it returns the first option and if not the second:

=IF(
  COUNTIFS(B1:B5, "Pick Up")>1, 
  SUMIFS(C1:C5, B1:B5, "Pick Up"), 
  SUMIFS(C1:C5, B1:B5, "Actuals")
)

Actually, the SUMIFS in the second option for Actuals isn't really necessary. If the only thing in the column is Actuals, then you can just use SUM:

=IF(
  COUNTIFS(B1:B5, "Pick Up")>1, 
  SUMIFS(C1:C5, B1:B5, "Pick Up"), 
  SUM(C1:C5)
)

Hope this helps.


The original answers are below. I edited them after sample data and clarity on the question was provided. They are left for historical purposes, or if someone looks at the edit history on the question, or if the edit isn't accepted.

EDIT: based on feedback in the comment. If you want to return the sum of Actuals when there are no Pick Ups, change the sumifs condition to countifs:

=IF(
  COUNTIFS(X97:X126,$D97:$D126,"Pick Up") > 0,
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

Original answer:

It's a little hard without some actual data, but I think your issue is that if your condition (the sumifs using "Pick Up") returns 0 then that's a falsy value, so it goes to the second output.

=IF(
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

Try this instead:

=IF(
  SUMIFS(X97:X126,$D97:$D126,"Pick Up") >= 0,
  SUMIFS(X97:X126,$D97:$D126,"Pick Up"),
  SUMIFS(X97:X126,$D97:$D126,"Actuals")
)

That way if the sumifs returns 0 (or greater) then you will get an explicitly TRUE value to use in the first part of the if, instead of a number that Excel is going to try to interpret as boolean.

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