Afiq Johari
Afiq Johari

Reputation: 1462

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

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!

Upvotes: 0

Views: 647

Answers (1)

chaeschuechli
chaeschuechli

Reputation: 160

I hope I got your question right. So you want to display three different values in one column? What is the ambition for that? If you are able to represent one status in one column, your life gets much easier... For example

Status A | Status B | Status C
------------------------------
    X          X
                         X
    X                    X
  ...        ...       ...

Behind every column you set the specific counter. I hope you can work with this.

Upvotes: 0

Related Questions