3 Replies Latest reply on Jun 3, 2016 4:46 AM by Michael Hesser

    Count Problem

    Haroldy Tevaras


      I am having problems with the count function in Tableau.



      I have a query




        count (cri) as couter

        from table

        group by RiskCategory, CRI


      and the results are as follows: \


      how do I replicate that in tableau? Not the tabular form, but the actual numbers for each risk category and CRI.  So far it returns several million records, and if I go with the minimum it retuns 6.


      Advice is greatly appreciated.



        • 1. Re: Count Problem
          Michael Hesser

          Hi Haroldy;



          If you are linking to the raw file, start by creating calculation called INDEX:

          Convert this into Discrete


          Now, drop INDEX, CRI and Riskcategory pills on the Rows


          Then drop Number of Records into Text. It will show up as SUM(Number of Records).


          I made up a simple database, but your results will look something like this:



          I hope this works for you! --Michael

          • 2. Re: Count Problem
            Haroldy Tevaras

            Hi Michael!


            Thanks for your help! It worked really well.


            Could you please explain to me why we had to add an index field?



            • 3. Re: Count Problem
              Michael Hesser

              Great question!

              Technically, the INDEX isn't necessary. I just added it to prevent the CRI column from aggregating, bringing it a little closer to the tabular format you showed.


              With INDEX, your results will look like this:

              Without INDEX your results will look something like this:

              The results remain the same: only the presentation changes. You may prefer the second viz over the first...


              If you like the first view but think the INDEX Column is confusing, you can hide it and every CRI will still be listed.

              1 of 1 people found this helpful