2 Replies Latest reply on Mar 29, 2016 7:48 AM by Nicholas Miller

    Add a member to a Field

    Nicholas Miller

      Good Afternoon Everyone,


      I feel that this should be a fairly quick and easy question, but I can't seem to find an answer.  I am looking to add a member to a current field in Tableau that currently does not exist in my data pull.  The count for this field will be "0" but will want to show that in some of our visualizations.


      So Example:


      Currently Being pulled in:


      Service            Count of Service

      Service A               1

      Service B               2

      Service C               3


      What I would like to do is add service D which will have a zero count.


      Thanks for the help!

        • 1. Re: Add a member to a Field
          Shawn Wallwork


          CASE [Service]

          WHEN 'Service A' THEN 1

          WHEN 'Service B' THEN 2

          WHEN 'Service C' THEN 3

          ELSE 0 END



          IFNULL([Service], 'Service D')

          • 2. Re: Add a member to a Field
            Nicholas Miller

            Thanks for the reply @Shawn.


            This would have worked, but there are now are few new issues that I need to explain.  First off, I don't want to have a case where I am assigning values, I need it to count how many values there are (number of records).  I am going to attach a sample workbook to explain this better.


            So In the attached workbook, is shows the number of records for Service A, B and C.  What I need is to add Service D, E, and F to the members of the [service type] (in additional to A,B,C) that shows they D,E,F have a 0 since they were not a member, all while in Tableau.  The reason behind this is as our records move, sometimes you will not see a service as it has no count but we want to see it in our table/visualizations in Tableau.


            Then I could use this calculated field in the Rows column and would result in this:


            Service            Count of Service

            Service A              1

            Service B              2

            Service C              3

            Service D              0

            Service E              0

            Service F              0


            So with that being said, I need to build a calculated field that checks that:


            if [Service type] does not contain "Service A" return "Service A" but if it does return [Service Type] and the same goes for the other 5 services (B-E).  I can't use ifnull in your suggestion due to needing to validate more than adding one addition service type.


            I have tried:

            If CONTAINS([Service type],"Service A")= FALSE THEN "SERVICE A"

            ELSEIF CONTAINS([Service type],"Service B")= FALSE THEN "SERVICE B"

            ELSE [Service type}



            Unfortunately, when I add the other services in this calculated its all tied to the first line of "service A" being False.