简体   繁体   English

如何编写一个Excel公式来根据另一列中的日期来计算一列中值的数量?

[英]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()代替A1B1 Change as applicable 更改适用

Screenshot 截图 在此处输入图片说明

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.

相关问题 在 excel VBA 中,如何根据另一列中的值变化将一列中的数字增加一列 - In excel VBA how do you increase a number in one column by one based on the value changing in another column 如何根据Excel中另一列的数据计算一列的总和? - How can I calculate the sum of one column based off of the data from another column in Excel? Excel 条件格式公式基于一列的最后日期为另一列中的某些条件 - Excel Conditional Formatting formula based on the last date of one column for certain criteria in another column Excel公式|| 如何计算列中出现的值 - Excel Formula || How to count occurrences of a value in column 在Excel中,我可以编写一个公式来根据另一列的内容计算一列的总和吗? - In Excel can I write a formula that will calculate the sum of a column based on the contents of another column? 如何在excel中创建一个公式来搜索行中的值,然后从该列中的另一个单元格中获取值? - How do I create a formula in excel that searches for a value in row, and then takes the value from another cell in that column? 在 excel 中,如何根据另一列中的条件返回一列中唯一值的数量 - In excel how can I return the number of unique values in one column based on criteria in another column Excel 公式根据另一列中的值填充一列 - Excel formula to fill a column based on value in another column Excel公式根据另一列值复制一列 - Excel formula to copy a column based on another column value Excel-如何根据另一列中指定的日期范围确定一列中“ A”的数量? - Excel - How to determine the number of “A”s in one column based on a specified date range in another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM