Home » excel » excel – COUNTIFS formula – unique values

excel – COUNTIFS formula – unique values

Questions:

I would like to create one formula that will give me the desired result, which is number of unique IDs with “0” Amount. Below I have two formulas, but since the whole document has a lot of data, I would like to have one formula.

first formula counts how many times ID occurs in column A
=COUNTIFS(\$A\$2:\$A2,A2,\$G\$2:\$G2,”0″)

second formula counts how many unique IDs have “0” Amount in column G
=COUNTIFS(K2:K18,”1″,G2:G18,”0″)

sample of raw data:

``````ID      Amount
100075738   0
100075738   0
27258   312.76
27300   961.59
27372   316.96
27578   769.3
30609   0
33163   573.16
36245   0
36249   3365.6
42026   1563.8
47065   673.12
48966   442.33
100007640   1287.16
100010436   2615.55
100026622   692.44
100028235   1548.4
``````
If you have access to the new `Dynamic Array` formulas in excel you can use:
``````=COUNT(UNIQUE(FILTER(A2:A18,B2:B18=0)))
If you don’t have access to those, you can use this `Array` formula instead
``````=SUM(--(FREQUENCY(IF(B2:B18=0,MATCH(A2:A18,A2:A18,0)),ROW(A2:A18)-ROW(A2)+1)>0))