简体   繁体   English

计算满足条件的数组中的行数

[英]Count the number of rows in an array which met a criteria

I have a training records spreadsheet where i have the training modules in columns and the colleagues in rows. 我有一个培训记录电子表格,其中我在列中有培训模块,在行中有同事。 There is a complex department with many tasks where I want to count how many people have been trained on a specific day. 有一个复杂的部门,执行很多任务,我想计算在特定的一天有多少人接受了培训。

In other words, i would like to know within the array how many rows have the same value. 换句话说,我想知道数组中有多少行具有相同的值。 I've tried the below code but it gave me back the number of tasks which have been trained on that day: 我已经尝试了下面的代码,但是它给了我当天培训的任务数量:

=SUMPRODUCT(--($FZ$9:$GY$1915=DATEVALUE("01/02/2018")))

This is a more simple example of what I need: 这是我需要的一个更简单的示例:

    Task1   Task2
-------------------
    Date1   Date2
    Date1   Date1
    Date2   Date1

If I want to look for Date1, the result should be 3 , because it appears in 3 rows . 如果我要查找Date1,结果应该是3 ,因为它出现在3行中 When I put the below mentioned countif/sumif CSE formula, it counts how many times Date1 appears, which is 4. 当我输入下面提到的countif / sumif CSE公式时,它计算Date1出现的次数,即4。

I think this is one of the cases where you could benefit from a helper column. 我认为这是您可以从帮助专栏中受益的一种情况。 And example formula would be, for given example: 对于给定的示例,示例公式为:

Cell C2: 单元格C2:

=--OR(A2="Date1",B2="Date1")

Drag down (autofill if table) 向下拖动(如果有表格则自动填充)

Formula in D2: D2中的公式:

=COUNTIF(C2:C4,1)

Example in sheet: 工作表中的示例:

示例数据

You can use array Formulas. 您可以使用数组公式。 To do that, once you type the formula, press Ctrl + Shift + Enter togther. 为此,在键入公式后,请按Ctrl + Shift + Enter键 The formula you will use is - 您将使用的公式是-

=sum(if($FZ$9:$GY$1915=DATEVALUE("01/02/2018"),1,0))

See the example below - 请参阅以下示例- 在此处输入图片说明

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

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