I have a big data set with the structure as shown below.
Operation | User | Timestamp | Elapsed time |
---|---|---|---|
12 | 1 | 2018-01-03 | 11:19:02 AM |
12 | 1 | 2018-01-03 | 12:34:02 PM |
12 | 1 | 2018-01-04 | 8:34:02 AM |
12 | 2 | 2018-02-03 | 9:34:02 AM |
12 | 2 | 2018-02-03 | 11:12:42 AM |
12 | 3 | 2018-02-03 | 12:12:00 PM |
15 | 1 | 2018-01-02 | 9:22:32 AM |
15 | 1 | 2018-01-02 | 9:25:32 AM |
15 | 2 | 2018-01-02 | 9:25:32 AM |
The goal is to form the column "Elapsed Time" using DAX and PowerBI. The column shows the difference/duration between the current timestamp and previous timestamp for the same user and the same operation.
I've tried something along the lines of:
Elapsed time =
DATEDIFF (
CALCULATE (
MAX ( data[Timestamp] ),
ALLEXCEPT ( data, data[Operation], data[User] ),
data[Timestamp] < EARLIER ( data[Timestamp] )
),
data[Timestamp],
MINUTE
)
`
But it complains about a single value for column 'Timestamp' in table 'data' cannot be determined. this can happen when a measure formula refers to a column that contains many values without specifying an aggregator such as min, max, count, or sum to get a single result.
I'm very new to DAX, so I'd appreciate any help.