Please see attached workbook (2018.2) and below screenshots which gets you what you're looking for:
This calculation computes the Exit calculation, a LOOKUP function which looks not at row 0 or the row preceding but the next row:
This calculation computes the number of seconds between First Moved and the new Exit calculation; and if it is the last row in the partition to make it '0'.
This is a copy of Jonathan Drummey's calculation uses the SUM of Exit Seconds to determine total duration or difference between First Moved and Exit. Because you have 'days' in between movement, this calc is needed and a simple DateDiff will not suffice nor format correctly.
This is the related Table Calculation needed for Exit Seconds to set the order of displaying the results correctly.
This is the related Table Calculation needed for the Exit Calculation to display the last time value as Null:
If this answers your question, please mark this response as correct. Hope it helps! Thx, Don
car movements flow.twbx 2.4 MB
Thanks Don WISE ,
This is really good and the numbers correct. How do I talk these numbers and and get a average for the description removing first moved, vehicle id from the rows section and just having Description and Average Differecne. To get a average time at those descriptions, Is this possible in Tableau?. .... Like a average if function just for those description
The downside of being able to get you correct numbers is that I'm using Table Calculations to specifically get them; which in turn, doesn't allow Tableau to further aggregate (use an Average) on a calculation that's already aggregated.
The issue is the [Exit] time/date calc that you needed. That's a table calculation using the LOOKUP function; so thereafter, any type of further aggregation efforts will error out. If your [Last Moved] timestamp was actually the correct data (date/timestamp), instead of creating it using the [Exit] calculation to mimic it, then we could potentially get you to an average using a slightly similar methodology but involving an AVG LOD calc.
In looking at your [Last Moved] data, I completely understand why you needed a new [Exit] timestamp...If you can get a column of data which is better for [Last Moved], then I can go forward...Thx, Don