5 Replies Latest reply on Jun 25, 2016 9:43 PM by Mahfooj Khan

    Tableau - Calculated Field : repeat count when multiple conditions are met

    Afiq Johari

      This is a column

       

       

          Status  Count

          A B C   1000

          A B     500

          B D     200

          C D     100

       

       

      I have a column named Status where each row contains all the different status taken by a person.

       

       

      I'm trying to create a calculated field which should give the following table

       

       

          Status|  Status A|  Status B|  Status C|  Status D|

          A B C |      1000|      1000|      1000|         0|

          A B   |       500|       500|         0|         0|

          B D   |         0|       200|         0|       200|

          C D   |         0|         0|       100|       100|

       

       

      Here's an attempt

       

       

          IIF(CONTAINS([Status],"A"),"Status A",

           IIF(CONTAINS([Status],"B"),"Status B",

           IIF(CONTAINS([Status],"C"),"Status C",

                       IIF(CONTAINS([Status],"D"),"Status D","")))

       

       

      The returned result using the calculated field above is however:

       

       

          Status|  Status A|  Status B|  Status C|  Status D|

          A B C |      1000|         0|         0|         0|

          A B   |       500|         0|         0|         0|

          B D   |         0|       200|         0|         0|

          C D   |         0|         0|       100|         0|

       

       

      Can someone help me out with this?

      I truly believe the solution would be simple.

       

       

      Thanks!

       

      Message was edited by: Afiq Johari updated results presentation.