6 Replies Latest reply on Feb 8, 2017 1:18 PM by michel.khennafi

    Count Distinct


      Hello to all:


      I have a field "Facility Type" that can take 2 values (Plant or DC). I am trying to determine the distinct count of facilities by facility type and use the result as a measure in a table... I tried countd(), count() with table calculation but I cannot get the result I need.


      I have attached an image showing the data in the extract and the desired result... Anyone can help on this one?


      Truly appreciated!



        • 1. Re: Count Distinct
          Tom W

          Drag your business dimension onto the rows shelf, then put facility type on columns. Add the distinct count onto the body of the report.

          • 2. Re: Count Distinct

            Thank you so much for taking the time. Your proposed solution does not allow me to add additional measures / column onto the table... all additional measures come under the column header causing the number of faccilities to duplicate in every pane... is there a possibility to have the number of facilities per facility type only one in the table?

            • 3. Re: Count Distinct
              Tom W


              There isn't much I can do to help without a sample of your data in Tableau. Please attach a Tableau Packaged Workbook.

              • 4. Re: Count Distinct



                Truly appreciate your patience... Here is the sample data on first tab and the desired result on separate tab... the plant / depot and carrier counts are count distincts of the values in the database. I created an extract for my data.

                • 5. Re: Count Distinct
                  Tom W

                  Thanks for the example, it's still not 100% clear though as there's no calculations.

                  Here's what I think you need to do; create a couple of calculations like:

                  COUNTD(IF [Facility Type] = 'Plant' then [Facility] END)




                  COUNTD(IF [Facility Type] = 'DC' then [Facility] END)


                  Tehn drag 'Measure Names' onto columns, and drag the 'Measure Values' onto the 'text' button on the marks card. Then you can select your newly created calculations from above and the SUM of the cost field and the COUNT DISTINCT of the Carrier field.

                  • 6. Re: Count Distinct

                    Truly Appreciated Tom... It worked just fine as explained in your last post