https://exceljet.net/formula/count-unique-text-values-in-a-range
Excerpt from the site:
Handling empty cells in the range
If any of the cells in the range are empty, and you want to use FREQUENCY instead of COUNTIF, you'll need use a more complicated array formula that includes IF:
Note: because the logical test portion of the IF statement contains an array, the formula becomes an array formula that requires Control-Shift-Enter. This is why SUMPRODUCT has been replaced with SUM.