COUNTIF, counts based on the criteria in the second argument.
So for example if you have
Book1 |
---|
|
---|
| A | B | C | D |
---|
1 | 1 | 1 | | 2 |
---|
2 | 2 | | | |
---|
3 | 3 | | | |
---|
4 | 1 | | | |
---|
5 | 2 | | | |
---|
6 | 3 | | | |
---|
7 | 2 | | | |
---|
8 | 5 | | | |
---|
|
---|
It counts all the cells in A1:A8 that are equal to the value in B1 (that is 1). Answer is one value and it counts it 2 times.
Now if you give the criteria argument an array, lets say:
Book1 |
---|
|
---|
| A | B | C | D |
---|
1 | 1 | 1 | | 2 |
---|
2 | 2 | 2 | | 3 |
---|
3 | 3 | | | |
---|
4 | 1 | | | |
---|
5 | 2 | | | |
---|
6 | 3 | | | |
---|
7 | 2 | | | |
---|
8 | 5 | | | |
---|
|
---|
It does the same, first counts the 1's, and then it counts the 2's., and the result is an array of length 2, with the count of 1's (counts 2) and the count of 2's (counts 3).
What the formula you provided does, is it counts the total number of appearances of every value in the array being the criteria array the same as the data array.
Book1 |
---|
|
---|
| A | B | C | D |
---|
1 | 1 | | | 2 |
---|
2 | 2 | | | 3 |
---|
3 | 3 | | | 2 |
---|
4 | 1 | | | 2 |
---|
5 | 2 | | | 3 |
---|
6 | 3 | | | 2 |
---|
7 | 2 | | | 3 |
---|
8 | 5 | | | 1 |
---|
|
---|
If you analice the result of the result array of COUNTIF it is:
| | | | | | | |
| | | | 1 | 2 | 3 | 5 |
1 | | | 2 | 2 | | | |
2 | | | 3 | | 3 | | |
3 | | | 2 | | | 2 | |
1 | | | 2 | 2 | | | |
2 | | | 3 | | 3 | | |
3 | | | 2 | | | 2 | |
2 | | | 3 | | 3 | | |
5 | | | 1 | | | | 1 |
|
---|
For the criteria "1" you get 2 counts of 2, for the criteria "2", you get 3 counts of 3, for criteria "3" you get 2 counts of 2, and finally for criteria "5" you get 1 count of 1.
Then your formula divides 1 in that numbers.
if you add the those numbers up, you add 1 for the "1" criteria, 1 for the "2" criteria, and so one. So you add a total of 4.
Hope this helps