[英]How do I write an excel formula to count the number of a value in one column based off of a date in another column?
I have a worksheet and I'm trying to do a simple Count function, probably a countif but I'm unsure how to go about writing the formula. 我有一个工作表,我正在尝试做一个简单的Count函数,可能是一个countif,但是我不确定如何去写公式。
I have two columns that I'd like to use for this formula. 我有两列要用于此公式。
Column N - I would like to filter for the Criteria of "C" or anytime a cell has a value of C N列-我想过滤条件“ C”或任何时候单元格的值为C
Column 0 - This column has dates filled in (short date format). 列0-此列中填写了日期(短日期格式)。
I would like to get a count of every C for each month, as simple as that. 我想获得每个月每个C的计数,就这么简单。
In this example I filtered the date for May of 2017 and filtered for C under the Check column. 在此示例中,我过滤了2017年5月的日期,并在“检查”列下过滤了C。 We can see that there are 12 instances of C showing in the month of May 2017.
我们可以看到2017年5月有12个C实例显示。
Does anyone know how to structure a formula that I would be able to Count the Number of C's for every month into the foreseeable future? 有谁知道如何构造一个公式,使我能够在可预见的将来计算每个月的C数量?
I figured out how to count the total present in a date range but unsure of how to add the date range plus Column N (Check) every time "C" is present in the cell. 我想出了如何计算日期范围内的总数,但不确定每次单元格中出现“ C”时如何添加日期范围以及列N(检查)。
=SUMPRODUCT((O:O>=DATEVALUE("5/1/2017"))*(O:O<=DATEVALUE("5/31/2017")))
Try this 尝试这个
=COUNTIFS(O1:O100,">="&A1,O1:O100,"<"&B1,N1:N100,"C")
Where A1
has the start date and B1
has the end date for that month. 其中
A1
具有该月的开始日期,而B1
具有该月的结束日期。 You can use DATEVALUE()
instead of A1
and B1
. 您可以使用
DATEVALUE()
代替A1
和B1
。 Change as applicable 更改适用
If you want to use SUMPRODUCT
then see this 如果要使用
SUMPRODUCT
请参见此
=SUMPRODUCT((O:O>=DATEVALUE("1/5/2017"))*(O:O<=DATEVALUE("30/5/2017"))*(N:N="C"))
In another column (lets say 'P' for example) I would insert a formula to give you the month number =Month(P7)
- this will return 5 for May. 在另一列中(例如,让我们说“ P”),我将插入一个公式来为您提供月数
=Month(P7)
-这将为5月返回5。
I would then use COUNTIFS (Like COUNTIF but it uses multiple criteria) to count where column N contains 'C' and column 'P' contains '5'. 然后,我将使用COUNTIFS(类似于COUNTIF,但它使用多个条件)来计算N列包含“ C”和P列包含“ 5”的位置。
=COUNTIFS(N:N,"C",P:P,5)
Try this....you need to select the entire Column B and named the column as 'Date'. 尝试此操作。...您需要选择整个列B并将该列命名为“日期”。 enter image description here
在此处输入图片说明
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.