KNOWLEDGE BASE

Getting Distinct Count When COUNTD Is Not Available


Published: 21 Aug 2013
Last Modified Date: 06 Feb 2017

Question

How to get the distinct count for a field when COUNTD is not available.

Environment

Tableau Desktop

Answer

Step 1: Create a WINDOW_SUM Calculation

  1. In Tableau Desktop, connect to Superstore sample data.
  2. Select Analysis > Create Calculated Field.
  3. In the Calculated Field dialog box that opens, enter a name for the field. The COUNTD Alternative example workbook uses Distinct Customers.
  4. In the formula field, type the following, and then click OK:
    WINDOW_SUM(MIN(1))
  5. Drag Distinct Customers from Measures to Columns.
  6. Drag the dimension for which you want the distinct count from Dimensions to Detail. The example workbook uses Customer Name
  7. Right-click Distinct Customers on Columns, and then select Compute Using > Customer Name.

Step 2: Filter on Index

  1. Select Analysis > Create Calculated Field to create another calculated field.
  2. In the Calculated Field dialog box, type a name for the field. The example workbook uses Table Calc Filter.
  3. In the formula field, type the following, and then click OK:
    INDEX()=1
  4. Drag Table Calc Filter from Measures to Filters, and then click OK (do not tick any available option).
  5. Drag Product Category from Dimensions to Rows.
  6. Right-click Table Calc Filter on Filters, select Compute Using > Customer Name, select True, and then click OK.
  7.  

Additional Information

Any additional measures in the view will also need to use table calculations such as WINDOW_SUM.
Did this article resolve the issue?