Please use the below formula in a calculated field.
if min([User ID]) = LOOKUP(min([User ID]),-1) then
min([Order Date]) - LOOKUP(min([Order Date]),-1)
Also see to the attached Tableau Workbook with the same.
Let me know if this helps.
Date difference.twbx 16.5 KB
You can use the below post to do the calculation between dates. Here basically you need to calculate the difference between two dates
Thanks for your answers. Unfortunately your solutions works just when you put the formula in a visualization that does the grouping by user id on its own.
I have a million different users with millions of transactions, I don't need to have it working in a visualization
I need it to work correctly as a calculated field on the all data source, so that then I can use this calculated field as parameter to filter.
I think there might be a way using function Fixed "userid" but I still couldn't figure out the right way to do it