I'd trying to calculate a duration of an event for use in a chart within Tableau. The database table has a unique event id, but each event id has 2 or more state values (e.g. start of event, change to event, end of event). I'm trying to calculate the time difference using the timestamp column within the table, where I want to subtract the date/time where state value = 1 from the data/time where state value=0 for each event id. I've tried the various DATE functions, but to no avail. Any ideas would be greatly appreciated.