Excel数组countif公式

时间:2018-01-04 13:02:08

标签: arrays excel excel-formula countif

我想使用COUNTIF函数来评估2,0,0,5中有多少项大于2?在Countif函数中,第一个参数是范围,第二个参数是条件。我试过以下公式。甚至尝试使用Ctrl + Shift + Enter来评估。但似乎没有用。

=COUNTIF({"2","0","0","5"},">2")

2 个答案:

答案 0 :(得分:3)

private void sortOldToNew() { if (inspectionDataArrayList == null) inspectionDataArrayList = new ArrayList<>(); Collections.sort(inspectionDataArrayList, new Comparator<ClsInspection>() { public int compare(ClsInspection o1, ClsInspection o2) { String strDt1 = o1.getInspectionDateTime(); // your first date here String strDt2 = o2.getInspectionDateTime(); // second date here if (Utility.isValueNull(strDt1) || Utility.isValueNull(strDt2)) return 0; else { Date dt1 = Utility.convertStringDateToDate(GMT_DATE_FORMAT, strDt1); Date dt2 = Utility.convertStringDateToDate(GMT_DATE_FORMAT, strDt2); if (dt1 == null || dt2 == null) return 0; return dt1.compareTo(dt2); } } }); setAdapter(inspectionDataArrayList); } 不接受数组常量(据我所知)。试试这个:

String GMT_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";

你也可以像这样创建一个countif风格的公式(组合ctrl + shift + enter):

COUNTIF

答案 1 :(得分:0)

推荐阅读: Array vs Range

Offset,SumIf,CountIf,SumIfs和CountIfs等函数只能在(多单元格)范围对象上运行。 Sum,SumProduct,Frequency,Linest,lookup函数等同时包含范围和数组对象。

数组意味着: {2,0,0,5}

范围表示:

enter image description here

要使用countif,您必须在单元格中使用范围,在运动中定义公式中的数组将无效。

=COUNTIF(A1:A4,">"&2)