有朋友傳來數據:
公式解析
總公式:
=IF(C2=0,””,(C2<>0)*(COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″)))
解釋:
如果C=0,則返回值是0,否則返回(C2<>0)*(COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″))的計算結果。
公式(C2<>0)*(COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″))含義:
C2<>0,是以邏輯值:
如果滿足C2<>0,則返回TRUE,計算時按1計算;
如果C2=0,則返回FALSE,計算時按0計算。
即:
如果C2<>0,則1*(COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″));
如果C2=0,則0*(COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″));
COUNT($C$2:C2)-COUNTIF($C$2:C2,”0″)):
$C$2:C2是隨公式向下填充,始終以C2位起始單元格的、范圍逐漸擴大的動態區域;
COUNT()-COUNTIF()的含義是:
區域中所有單元格數量—為0的單元格數量,即是不為0的單元格數量。