3 Replies Latest reply on Mar 3, 2016 11:59 AM by Patrick A Van Der Hyde

# Calculated Field - If, then, filter by

Hello,

I am new to Tableau and need help figuring out a way to create a filter for my data. This is a preview of the data I have:

 ID Status Date 1 (Placed) Date 2 (Fill) Date 3 (Start) 001 A 1/1/2016 1/21/2016 1/22/2016 002 B 1/2/2016 1/18/2016 1/19/2016 003 C 1/3/2016 1/10/2016 1/11/2016 004 D 1/4/2016 2/2/2016 2/3/2016 005 E 1/5/2016 1/8/2016 1/9/2016 006 B 1/6/2016 2/17/2016 2/18/2016 007 B 1/7/2016 1/29/2016 1/30/2016 008 C 1/8/2016 1/15/2016 1/16/2016 009 A 1/9/2016 2/5/2016 2/6/2016 010 A 1/10/2016 2/29/2016 3/1/2016 011 D 1/11/2016 2/10/2016 2/11/2016

What I am wanting the calculated field to do is, if the Status contains either A or B, then it will filter that row by Date 1 and give me the count. If Status contains C, then filter that row by Date 2 and give me the count. If Status contains either D or E, then filter that row by Date 3 and give me the count.

So my final sheet would look like this:

 Status Date 1 (Placed) Date 2 (Fill) Date 3 (Start) A or B 6 - - C - 2 - D or E - - 3

However, I don't see any part of the calculated field that would allow me to say "Filter by".

Any suggestions would be extremely helpful.

• ###### 1. Re: Calculated Field - If, then, filter by

Hello Raquel De Bastiani,

So we just need two calculated fields to accomplish this.  The first one is to summarize the Dates into three buckets:

If [Status]="A" or [Status]="B" then "Date 1 (Placed)"

elseif [Status]="C" then "Date 2 (Fill)"

elseif [Status]="D" or [Status]="E" then "Date 3 (Start)"

END

Then we need to summarized the Status fields - which is almost the same thing:

If [Status]="A" or [Status]="B" then "A or B"

elseif [Status]="C" then "C"

elseif [Status]="D" or [Status]="E" then "D or E"

END

Put the first one on Columns, the second on Rows and then a Count of ID on the view.

See attached.  Note that I cut/pasted the data from your view so I have the original header rows contained in the data resulting in a filter on Null.  Ignore that.

i hope this helps

Patrick

1 of 1 people found this helpful
• ###### 2. Re: Calculated Field - If, then, filter by

Patrick,

Thank you very much for your help, that worked perfectly!

• ###### 3. Re: Calculated Field - If, then, filter by

I am glad that helped. Thank you for coming back and commenting Raquel.  I have marked my answer as the "Correct Answer"  based on your feedback.

Have a great day

Patrick