10 Replies Latest reply on Nov 29, 2018 5:17 AM by Zhouyi Zhang

# Calculate Time difference based on condition

Hi All,

I have use case in my current requirement where in i have to calculate the time difference between 2 actions. I have sample data below.

I want to calculate time difference between action taken by "Team 3" from previous action for each Ticket Number. I do not want to use "Lookup" function here as i want to use aggregated measure in my view.

For instance, Ticket Number =101 , Time difference shuld be (1/1/17 3:08PM  - 1/1/17 1:52PM = 4560 secs)

Regards,

Shruthi

• ###### 1. Re: Calculate Time difference based on condition

Hi, Shruthi

Please find my solution by left join your data to itself as shown bleow. workbook attached for your reference.

Hope this helps

ZZ

• ###### 2. Re: Calculate Time difference based on condition

Thanks for your response,unfortunately as I'm connecting to Tableau server DS, i will not be allowed to do join. Could you please suggest any other resolution.

• ###### 3. Re: Calculate Time difference based on condition

then lookup is the only option....

ZZ

• ###### 4. Re: Calculate Time difference based on condition

Hi Zhouyi,

Is there a way to do string comparison in Fixed LOD function like below

{Fixed [Ticket Number] , [Team]="Team 3" : Max ([actioned date])}

• ###### 5. Re: Calculate Time difference based on condition

That's a very good point, just need your confirmation of 'Team 3' will be hard code, is that true?

ZZ

• ###### 6. Re: Calculate Time difference based on condition

Yes it can be, as in real time scenario also, I will be comparing it with only 1 team.

• ###### 7. Re: Calculate Time difference based on condition

@Zhouyi ,

With hard coding, do you see possibility in achieving the output?

• ###### 8. Re: Calculate Time difference based on condition

Hi, Shruthi

Sorry about the delay. Please find my update attached as well as below screenshot for reference.

Hope this helps

ZZ

1 of 1 people found this helpful
• ###### 9. Re: Calculate Time difference based on condition

Thanks Zhouyi for your response. This helped me in my work.

• ###### 10. Re: Calculate Time difference based on condition

No worries, I am glad to help

ZZ