I have the following data set:
Item || Date || Client ID || Date difference
A || 12/12/2014 || 102 ||
A || 13/12/2014 || 102 || 1
I used the following solution to deal with groups that had more than 2 rows/dates.
First create a calculated column to provide a rank order by date within each group:
RankDatePerUnit:
Rank([EventDate],[Group_Name])
Then another calculated column to do the date diff using an over expression to reference the previous date within the group.
TimeSinceLastEvent:
DateDiff("day",
First([EventDate]) OVER (Intersect([Group_Name], Previous([RankDatePerUnit]))),
[EventDate])
Note: Duplicate date could be handled differently by using denserank. The above approach will not calculate a zero date diff between two rows from the same group with a duplicate time. They'll both calculate their delta from an earlier date within the same group if one exists.