This is the formula that I use for computing count of unique values in a range of cells: SUMPRODUCT(1/COUNTIF(A5:A10,A5:A10&"")) Although this formula works fine in excel, error is thrown in POI with the following description: Invalid arg type for SUMPRODUCT: (org.apache.poi.ss.formula.eval.ErrorEval)