简体   繁体   English

当范围是一系列日期时,SUMIF

[英]SUMIF when the range is a range of dates

Here's what I want to do. 这就是我想要做的。
I have the following table: 我有下表: 在此输入图像描述

And another one that looks like this: 另一个看起来像这样: 在此输入图像描述

Here's what I want to do. 这就是我想要做的。 A SUMIF .. the range is the A column in the first table (picture 1) ...but the problem is here... the criteria is that I want the day in that date to be equal with the number in the 2nd table... and then I want to sum from column D. I tried the formula but it didn't work. 一个SUMIF ..范围是第一个表中的A列(图1)......但问题在于......标准是我希望该日期中的日期与第二个表中的数字相等...然后我想从D列中总结。我尝试了公式,但它没有用。 Could you help me with this situation? 你能帮我解决这个问题吗? Thanks! 谢谢!

Use this 用这个

=SUMPRODUCT((DAY(A1:A50)=A1)*(B1:B50))

Where
A1:A50 range of dates
A1 the day to find
B1:B50 The range of values to SUM

[]´s []的

You can also use an array formula: 您还可以使用数组公式:

=SUM(IF(DAY(Sheet1!$A$1:$A$11)=Sheet2!A2,Sheet1!$D$1:$D$11,0))

Enter the formula text with Ctrl+Shift+Enter. 使用Ctrl + Shift + Enter输入公式文本。

" the criteria is that I want the day in that date to be equal with the number in the 2nd table " 标准是我希望该日期的那一天与第二张表中的数字相等

As a date consists of a day AND month, year , just to provide a day as parameter isn't enough. 由于日期包括一天和一个月,一年 ,只是提供一天作为参数是不够的。 If your intention is eg to get a total "per day in the current MM/YY"YYY you know what to do - create two fields for the YYYY and MM you want to look at in the table header. 如果您的目的是例如获得“当前MM / YY中的每天”YYY,那么您知道该怎么做 - 为您想要在表格标题中查看的YYYY和MM创建两个字段。 Basically there is nothing wrong with using dates in a SUMIF directly, like in 基本上在SUMIF中直接使用日期没有任何问题,例如

=SUMIF($A$1:$A$15,DATE(2011,9,F1),$B$1:$B$15)

because at the end a date is a number. 因为最后一个日期是一个数字。

Alternatively you may use a Pivot table which aggregatees by day whatever date you have in the list, and you can sort/filter on any key field. 或者,您可以使用数据透视表,该数据表按日汇总列表中的任何日期,您可以对任何关键字段进行排序/过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM