Search code examples
excelexcel-formulauniqueexcel-2016

Count unique distinct values


I would like to count how many unique distinct scopes a certain country has in the table. The country may appear more than once in the table, in this case it has a different id (row B=”note”). The country may have more than one scope.

In the example below there should be a number 4, because France with id 483, 484, 485 and 486 has scope 9001 (i.e. 4 times).

I have tried to use the following formula, but I think I am stuck…

=SUM(IF(("France"=Findings!E2098:E5000)*("9001"=Findings!H2098:H5000), 1/COUNTIFS(Findings!E2098:E5000, "France", Findings!B2098:B5000, Findings!B2098:B5000, Findings!H2098:H5000, "9001")), 0) enter image description here


Solution

  • Here is another way of counting using FREQUENCY:

    enter image description here

    Formula in F1:

    =SUM(--(FREQUENCY(IF(D2:D15=9001,IF(C2:C15="France",MATCH(A2:A15,A2:A15,0))),ROW(A2:A15)-ROW(A2)+1)>0))
    

    Enter through CtrlShiftEnter