DSUM:如何使用大括号定义标准范围?

发布于 2024-08-16 02:22:55 字数 276 浏览 2 评论 0原文

我认为用一个例子来解释我的问题更容易:

alt text

基于上面的电子表格,公式 =DSUM(A4:D8,B4,A1:A2) 有效,返回 20。

为什么 =DSUM(A4:D8,B4,{"OrderID";">10567 “}) 不起作用? (它返回#VALUE!)

I think that it's easier to explain my problem with an example:

alt text

Based on the spreadsheet above, the formula =DSUM(A4:D8,B4,A1:A2) works, returning 20.

Why =DSUM(A4:D8,B4,{"OrderID";">10567"}) does not work? (It returns #VALUE!)

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

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

发布评论

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

评论(4

浸婚纱 2024-08-23 02:22:55

根据此页面上有关 D-Functions 的说明,我认为您需要单独单元格中的标准。

编辑:如果在公式中包含条件的目标是使其更具可读性,您可以使用命名范围 代替。

编辑2:回应您的评论
由于 DSUM() 函数的工作原理,无法执行您想要的操作(在公式中包含条件)。查看 DSUM 文档 并与 VLOOKUP 进行比较:

DSum 函数的语法为:

DSum(范围、字段、条件)

范围是您要应用条件的单元格范围。

field 是对值求和的列。您可以指定列表中列的数字位置,也可以用双引号指定列标签。

条件是包含您的条件的单元格范围

注意区别:

VLookup 函数的语法为:

VLookup( 值、table_array、index_number、not_exact_match )

value 是要在 table_array 的第一列中搜索的值。

table_array 是两个或多个按升序排序的数据列

index_number 是 table_array 中必须返回匹配值的列号。第一列是 1。

由于 DSUM 正在查找包含条件的单元格范围,因此您无法避免传递它 - 单元格范围。

我认为您能做的最好的事情就是将不同的标准定义为命名范围,这将使根据您想要在公式中执行的操作更轻松地引用不同的标准。不幸的是,如果常规 SUM 函数对您来说不够快,您就无能为力 - 您必须在单元格中指定条件才能使用 DSUM

Based on what's said about D-Functions on this page, I think you need to have the criteria in a separate cell.

EDIT: If the goal of including the criteria in the formula is to make it more readable, you could work with named ranges instead.

EDIT 2: In response to your comments.
It's not possible to do what you want (include the criteria in the formula) because of how the DSUM() function works. Take a look at the documentation for DSUM and compare it with VLOOKUP:

The syntax for the DSum function is:

DSum( range, field, criteria )

range is the range of cells that you want to apply the criteria against.

field is the column to sum the values. You can either specify the numerical position of the column in the list or the column label in double quotation marks.

criteria is the range of cells that contains your criteria.

Note the difference:

The syntax for the VLookup function is:

VLookup( value, table_array, index_number, not_exact_match )

value is the value to search for in the first column of the table_array.

table_array is two or more columns of data that is sorted in ascending order.

index_number is the column number in table_array from which the matching value must be returned. The first column is 1.

As DSUM is looking for a range of cells that contain the criteria, there's nothing you can do to avoid passing it just that - a range of cells.

I think the best you can do is define your different criteria as named ranges, which will make it a lot easier to reference the different ones depending on what you want to do in the formula. Unfortunately, if the regular SUM function is not fast enough for you, there's not much else you can do - you will have to specify criteria in cells to use DSUM.

上课铃就是安魂曲 2024-08-23 02:22:55

您可以使用 SUMIF(A5:A8;>10567;D5:D8)。一个非常有用但未充分利用的功能。

第二个参数可以是对具有该条件的另一个单元格的引用。

You may use SUMIF(A5:A8;>10567;D5:D8). A very useful and underused function.

The 2nd parameter may be a REF to another cell with the condition.

庆幸我还是我 2024-08-23 02:22:55

来自 DSUM 文档

条件是单元格范围
包含您的条件
指定。您可以使用任何范围
标准参数,只要它
包括至少一个列标签并且
该列下方至少有一个单元格
指定条件的标签
对于该列。

VLOOKUP 使用值数组。

table_array 必需。范围为
包含数据的单元格。你可以
使用对范围的引用(例如
例如,A2:D8) 或范围名称。

From DSUM documentation

Criteria is the range of cells that
contains the conditions that you
specify. You can use any range for the
criteria argument, as long as it
includes at least one column label and
at least one cell below the column
label in which you specify a condition
for the column.

VLOOKUP uses an array of values.

table_array Required. The range of
cells that contains the data. You can
use a reference to a range (for
example, A2:D8), or a range name.

許願樹丅啲祈禱 2024-08-23 02:22:55

Dsum 很糟糕,试试这个:
=SUMPRODUCT((A5:A8>10569)*(B5:B8))

一般来说,我建议你不要硬编码这样的东西,这是“不好的做法”,但随你喜欢。

Dsum sucks, try this:
=SUMPRODUCT((A5:A8>10569)*(B5:B8))

Generally I would advise you not to hard code stuff like this, it's "bad practice", but as you like.

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