Forum Discussion
RichardT_78
5 years agoHelper I
Time
Hi I have used this code to determine the time difference between rows as a messure. This looks at each row of data. Time Difference Measure13 = VAR NextRow = CALCULATE ( MIN ( FAC[S...
- Anonymous5 years ago
Hello @RichardT_78 ,
You can update your measurement as below screenshot shown, please find more details in the attachment:
Time Difference = VAR _nexindex = CALCULATE ( MIN ( 'FAC'[Index] ), FILTER ( ALLEXCEPT ( 'FAC', 'FAC'[Consist] ), 'FAC'[Index] > MAX ( 'FAC'[Index] ) ) ) VAR _nexttime = CALCULATE ( MAX ( 'FAC'[Start Date/Time] ), FILTER ( ALLEXCEPT ( 'FAC', 'FAC'[Consist] ), 'FAC'[Index] = _nexindex ) ) RETURN DATEDIFF ( SELECTEDVALUE ( 'FAC'[Start Date/Time] ), _nexttime, SECOND ) + 0Best regards
RichardT_78
5 years agoHelper I
| Consist | Start Date/Time |
| 377436 | 01/12/2020 13:08:51 |
| 377436 | 01/12/2020 13:08:50 |
| 377153 | 01/12/2020 13:06:32 |
| 377153 | 01/12/2020 13:06:30 |
| 377408 | 01/12/2020 13:04:51 |
| 377436 | 01/12/2020 13:04:40 |
| 377436 | 01/12/2020 13:04:39 |
| 377140 | 01/12/2020 13:02:14 |
| 377140 | 01/12/2020 13:02:12 |
| 377436 | 01/12/2020 13:01:00 |
| 377436 | 01/12/2020 13:00:59 |
| 377424 | 01/12/2020 12:59:54 |
| 377424 | 01/12/2020 12:59:51 |
| 377447 | 01/12/2020 12:59:40 |
| 377104 | 01/12/2020 12:59:36 |
377436 would be a good test as its spread over the table
So are for example 100 consist codes, which all have a time stamp for each particular event.
When I use a slicer and select 377104 for example, it displays all events chronologically, but the messure fails.
As you can see the messure works fine when you dont focus on a consist, but when i select a consist its rows are not consecutive.
Hope this helps , much appricated
Anonymous
5 years agoNot applicable
Hello @RichardT_78 ,
You can update your measurement as below screenshot shown, please find more details in the attachment:
Time Difference =
VAR _nexindex =
CALCULATE (
MIN ( 'FAC'[Index] ),
FILTER (
ALLEXCEPT ( 'FAC', 'FAC'[Consist] ),
'FAC'[Index] > MAX ( 'FAC'[Index] )
)
)
VAR _nexttime =
CALCULATE (
MAX ( 'FAC'[Start Date/Time] ),
FILTER ( ALLEXCEPT ( 'FAC', 'FAC'[Consist] ), 'FAC'[Index] = _nexindex )
)
RETURN
DATEDIFF ( SELECTEDVALUE ( 'FAC'[Start Date/Time] ), _nexttime, SECOND ) + 0
Best regards