2 Replies Latest reply on Jan 2, 2014 6:53 AM by Jonathan Drummey

    Question regarding counting a group

    Chaya Gordon Burstyn

      I have a group that I created out of my "company name" dimension so that certain companies on my list would be part of a single group, In my list of dimensions it has a paperclip next to it and is now called "company name (group)"


      I have a calculated field that counts "company name" with the simple count distinct formula COUNTD([Company Name]).


      However, I would actually like to count the group dimension rather than the company name dimension.


      For example, if I had 50 company names to start with and I grouped them into 5 groups, on my chart I would like that count formula to show the count as 5, not 50, but I am unable to choose that group from the list of dimensions when I am creating the formula.


      Is there anyway to count a grouped dimension?


      Thank you.

        • 1. Re: Question regarding counting a group
          Joshua Milligan



          You are absolutely correct that you cannot use a group in a calculated field.  However, you can use a calculated field to accomplish grouping and then another calculation to do the counts.


          You might try a calculation like this:


          [Company Group]

          CASE [Company Name]
          WHEN "ABC" THEN "Group 1"
          WHEN "DEF" THEN "Group 1"
          WHEN "GHI" THEN "Group 2"
          WHEN "XYZ" THEN "Group 10"


          Then another calcluation:

          COUNTD([Company Group]) to count the group.


          Hope that helps!




          • 2. Re: Question regarding counting a group
            Jonathan Drummey

            Another option is to set up a mapping table and either use that in a multiple tables connection or a data blend. I've found Tableau's ad-hoc groups to be wonderful for exploratory analysis, but given this limitation about use in calculated fields I'll move that linking into mapping tables (also called dimension tables) in the data source.