Friday, July 27, 2018

Excel: count UNIQUE numeric values in column


PROBLEM

 Count DISTINCT values in Excel column.

SOLUTION 


Copy-paste formula substituting the column range:
=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(A7,ROW(A7:A10000)-ROW(A7),,1)),A7:A10000),A7:A10000),1))

Similar with Excel Table ranges:
=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(Table1[[#Headers],[T_TBL_ID]],ROW(Table1[T_TBL_ID])-ROW(Table1[[#Headers],[T_TBL_ID]]),,1)),Table1[T_TBL_ID]),Table1[T_TBL_ID]),1))

Example:




DETAILS


The formula formatted break down:


=SUM(IF(
        FREQUENCY( 
                  IF( SUBTOTAL(3,
                                  OFFSET(Table1[[#Headers],[T_TBL_ID]],
                                         ROW(Table1[T_TBL_ID])-ROW(Table1[[#Headers],[T_TBL_ID]])
                                         ,,1))
                              ,Table1[T_TBL_ID])
                    ,Table1[T_TBL_ID])
                  ,1)
      )
    )

No comments:

Post a Comment