简体   繁体   English

如何在Excel中编写Countifs公式?

[英]How to write a Countifs formula in Excel?

When I drag or copy the formula to another cell then the date should be changed. 当我将公式拖动或复制到另一个单元格时,应该更改日期。 Every time I need to change the date manually. 每次我需要手动更改日期。

Only date should change when I drag the formula as this is a monthly. 当我拖动公式时,只有日期应该更改,因为这是每月。

Example is given below. 示例如下。

=COUNTIFS($M$35:$M$1007,”=1/9/2018″,$N$35:$N$1007,”TS”,$O$35:$O$1007,”HP”,$P$35:$P$1007,”1″)
=COUNTIFS($M$35:$M$1007,”=2/9/2018″,$N$35:$N$1007,”TS”,$O$35:$O$1007,”HP”,$P$35:$P$1007,”1″)
=COUNTIFS($M$35:$M$1007,”=3/9/2018″,$N$35:$N$1007,”TS”,$O$35:$O$1007,”HP”,$P$35:$P$1007,”1″)

Use the DATE function to return a true date. 使用DATE函数返回真实的日期。 The DATEVALUE function is an alternative but I prefer DATE. DATEVALUE函数是替代方法,但我更喜欢DATE。 Don't quote numbers. 不要引用数字。 Try not to use ambiguous DMY/MDY dates for examples. 例如,尽量不要使用模棱两可的DMY / MDY日期。 You don't need equals (eg = ) signs in a COUNTIFS. 您在COUNTIFS中不需要等号(例如= )。

Quoted strings do not change when dragged or copied to a new location. 拖动或复制到新位置时,带引号的字符串不会更改。 You need to include something that changes. 您需要包括一些更改。

I've assumed a DMY date system. 我假设一个DMY日期系统。 For 01-Sep-2018, 对于2018年9月1日,

=COUNTIFS($M$35:$M$1007, date(2018, 9, row(1:1)), $N$35:$N$1007, "TS", $O$35:$O$1007, "HP", $P$35:$P$1007, 1) 

Fill down for 02-Sep-2018, 03-Sep-2018, etc. 填写2018年9月2日,2018年9月3日等

Alternative for dragging across. 拖拉的替代方法。

=COUNTIFS($M$35:$M$1007, date(2018, 9, column(a:a)), $N$35:$N$1007, "TS", $O$35:$O$1007, "HP", $P$35:$P$1007, 1) 

Be careful about putting 'smart quote' in your formulas. 在公式中添加“智能引号”时要小心。 Your examples were littered with them and they don't work in formulas. 您的示例随处可见,它们不适用于公式。

You would need to define the dates you care about in their own column, and then make sure that the reference to them is unlocked within the formula: 您需要在自己的列中定义您关心的日期,然后确保在公式中解锁了对它们的引用:

 'A'         'B'
|date_field| formula                                                 |
----------- ----------------------------------------------------------
| 1/9/2018 |=COUNTIFS($M$35:$M$1007,$A1,$N$35:$N$1007,"TS", ... etc) |
----------- ----------------------------------------------------------
| 2/9/2018 |=COUNTIFS($M$35:$M$1007,$A2,$N$35:$N$1007,"TS", ... etc) |
----------- ----------------------------------------------------------
| 3/9/2018 |=COUNTIFS($M$35:$M$1007,$A3,$N$35:$N$1007,"TS", ... etc) |
----------- ----------------------------------------------------------

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

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