3 Replies Latest reply on Dec 4, 2016 2:24 PM by Maciek La

# Calculate the difference between two times

Hello, I am newbie in tableau, I need help with calculating time.

I have a table with information about time.

Id - number of a request

Stinc - Start Time of Requests

Fininc - End Time of Requests

difference - Difference (Fininc - Stinc)

I want to find time difference between Start Time of Requests (Stinc) and End Time of Requests (Fininc).

The table contains data chronologically,  because of that time values is in different rows.

I used the exclude filter (values null) but it applies to a non-zero rows too.

Probably formula will solve this problem, but I don't know which formula I need to use.

I would be grateful for any help.

• ###### 1. Re: Calculate the difference between two times

Hi Aleks,

Can you please share the sample data or workbook with us?

Thanks

• ###### 2. Re: Calculate the difference between two times

Hi Alex,

You can achieve this my using LOD. Logically speaking, you need to find minimum of STINC and max of FININC for each ID. This can be achieved as follows

1. Find min of STINC for each ID.

[Start Date]

{FIXED ID : MIN(STINC )}

2. Find min of FININC for each ID.

[End Date]

{FIXED ID : MAX(FININC)}

3. Now you can calculate the difference by subtracting 1 from 2

Best,

Sujay

1 of 1 people found this helpful
• ###### 3. Re: Calculate the difference between two times

This will work as long as IDs are unique. If 1 ID can have multiple occurences then it can cause issues.

Looking at the sample data - for me it's easiest to filter out nulls from both dates..