4 Replies Latest reply on Sep 29, 2008 9:41 AM by Erin Easter

    Counting Unique Values

    . bfaulkner

      I am struggling to figure out how to count unique values.  I have tried reading the help file on "Defining Unique Values" and I am still stuck.

       

      I have a list transactions that have the following information;

      - Amount

      - Date

      - Supplier

      - Department

       

      If I count the suppliers then I get the number of times the a supplier's name shows up in the dataset. 

       

      How do I count the number of Unique suppliers?

       

      I know it must be something easy but I am stuck.

       

      Thanks,

      Bruce

        • 1. Re: Counting Unique Values
          Erin Easter

          Bruce,



          What type of data source are you using? If you are using a local file data source such as Excel, Access, or Text Files you only have the ability to aggregate a field using Count. However, if you extract the data you can aggregate using Count (Distinct).



          You can create a Tableau Data Extract by selecting Data > Extract.

          • 2. Re: Counting Unique Values
            . bfaulkner

            Erin,

             

            I am using Excel.  Just gave it a try on the Supplier field and it worked perfectly.

             

            I have never used the Data > Extract feature and didn't even know to look there for the answer.

             

            Thank you very much.

             

            Regards,

            Bruce

            • 3. Re: Counting Unique Values
              guest contributor

              Hi -

              Can anyone comment on trying to do this when the data is coming from a SQL server?

              I'm trying to count the number of unique customers within market segments.  No matter what I've tried, I can only get the number of transactions by each customer.

              Thanks in advance!

              Kim

              • 4. Re: Counting Unique Values
                Erin Easter

                Hi Kim,

                 

                So with SQL Server you do not need to do a Data Extract to get the Count(Distinct) function. You should be able to drop your Market Segment field on the Rows shelf. Then drag a field that represents each unique customer (e.g., Customer Name, Customer ID,  etc.) to the Columns shelf. Finally, select Count Distinct as the aggregation on the field menu. So if you used Customer Name you will get the number of distinct customer names that are associated with each market segment.

                 

                Hope that helps!

                Erin