5 Replies Latest reply on Mar 6, 2013 9:45 AM by Sarah Gehrke

# Calculating phase duration using dates in Tableau

Hi,

I am trying to calculate how long various phases of a project took. There are many worksteps in the data set. I am using the start date of a work step and the end date of another work step to calculate duration. I haven't been able to figure out how to write a calculation that will compare the dates of the two work steps. The closest I have gotten is calculating end dates with today's date (but that isn't helpful).

For example, how many days did it take to move from USA to FICO (see data set for worksteps)

Any ideas? I have attached a small portion of my data set.

Thank you!!

• ###### 1. Re: Calculating phase duration using dates in Tableau

You could use a calculated field:

Days =  DATEDIFF('day',[Start],[Finish] )

You need to make sure the view is at the Work Step level of detail. For example Deal Name and Work Step are both rows. See attached.

• ###### 2. Re: Calculating phase duration using dates in Tableau

Sorry, I just reread your question and it looks like you want to calculate days between steps.

There are probably many ways of doing this and the best solution might depend on what you're trying to show. The easiest to understand (for me anyway) is to create a set of calculated fields. For example

Day FICO Started = IF [Work Step] == 'FICO' THEN [Start] END

Day USA Started = IF [Work Step] == 'USA' THEN [Start] END

Days between FICO and USA = DATEDIFF('day', ATTR([Day USA Started]), ATTR([Day FICO Started]))

Another approach if you wanted to calculate the time between each step for each deal, would be a table calculation:

Days from previous step = DATEDIFF('day', LOOKUP(ATTR([Start]),-1), LOOKUP(ATTR([Start]), 0))

This creates something like the below:

• ###### 3. Re: Calculating phase duration using dates in Tableau

Thank you for the quick response! Looking at your example, it looks like you have calculated duration of one workstep, which isn't what I am trying to calculate. I am looking to calculate duration from the beginning of one work step to the end of another. For example, How long did it take a Project to go from the start of SNL to the end of IRA.

Any thoughts?

Thank you again for your help!

• ###### 4. Re: Calculating phase duration using dates in Tableau

Hi Sarah,

Sorry I read your first message too quickly. Let me know if my second response makes sense. You'll have to edit those formulas slightly to get what you want, but I think it should be straight forward.

These calculated fields may get a bit unwieldy if, for example, you are trying to calculate the difference between all the different steps (and combinations)---in other words, if there is a particular view you have in mind there may be an easier solution.

Jim

1 of 1 people found this helpful
• ###### 5. Re: Calculating phase duration using dates in Tableau

Thank you!