DSUM:如何使用大括号定义标准范围?
我认为用一个例子来解释我的问题更容易:
基于上面的电子表格,公式 =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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
根据此页面上有关 D-Functions 的说明,我认为您需要单独单元格中的标准。
编辑:如果在公式中包含条件的目标是使其更具可读性,您可以使用命名范围 代替。
编辑2:回应您的评论。
由于
DSUM()
函数的工作原理,无法执行您想要的操作(在公式中包含条件)。查看 DSUM 文档 并与VLOOKUP
进行比较:注意区别:
由于
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 forDSUM
and compare it withVLOOKUP
:Note the difference:
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 useDSUM
.您可以使用 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.
来自 DSUM 文档
VLOOKUP 使用值数组。
From DSUM documentation
VLOOKUP uses an array of values.
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.