where date is the named range B5:B16. Note: In older versions of Excel, you can count unique items with the COUNTIF function, or the FREQUENCY function, as explained below. In the example shown, each row in the table represents a stock trade. On some dates, more than one trade is performed. The goal is to count trading days – the number of unique dates on which some kind of trade occurred. The formula in cell G8 is: Working from the inside out, the UNIQUE function is used to extract a list of unique dates from the named range date: The result is an array with 5 numbers like this: Each number represents an Excel date, without date formatting. The 5 dates are 1-Oct-20, 5-Oct-20, 7-Oct-20, 9-Oct-20, and 12-Oct-20. This array is delivered directly to the COUNT function: which returns a count of numeric values, 5, as the final result. Note: The COUNT function counts numeric values, while the COUNTA function will count both numeric and text values. Depending on the situation, it may make sense to use one or the other. In this case, because dates are numeric, we use COUNT.


In an older version of Excel, you can use the COUNTIF function to count unique dates with a formula like this: Working from the inside out, COUNTIF returns an array with a count for every date in the list: At this point, we have: After 1 is divided by this array, we have an array of fractional values: This array is delivered directly to the SUMPRODUCT function. SUMPRODUCT then sums the items in the array and returns the total, 5.


If you are working with a large set of data, you might have performance problems with the COUNTIF formula above. In that case, you can switch to an array formula based on the FREQUENCY function: Note: This is an array formula and must be entered with control + shift + enter, except in Excel 365. This formula will calculate faster than the COUNTIF version above, but it will only work with numeric values.  For more details, see this article.

Dave Bruns

Hi - I’m Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.