Forum Discussion
Difference between rows by Name by date
- 3 years ago
Hi JCKong
please try
Duration =
VAR CurrentTime = 'Table'[Punch Time]
VAR CurrentNameDateTable =
CALCULATETABLE (
VALUES ( 'Table'[Punch Time] ),
ALLEXCEPT ( 'Table', 'Table'[Name], 'Table'[Short Date] )
)
VAR TableAfter =
FILTER ( CurrentNameDateTable, 'Table'[Punch Time] > CurrentTime )
VAR NextTime =
MINX ( TableAfter, 'Table'[Punch Time] )
RETURN
COALESCE ( NextTime, CurrentTime ) - CurrentTime
Currently I use this but some of the Names doesn't show their duration:
Duration = VAR NextRow = CALCULATE ( SUM (Table[PunchTime]), FILTER (Table, Table[Index] = EARLIER (Table[Index]) + 1))) RETURN IF(Table[Activity] = "Logout", 0 , NextRow - Table[PunchTime])
- tamerj13 years ago
Community Champion
Hi JCKong
please try
Duration =
VAR CurrentTime = 'Table'[Punch Time]
VAR CurrentNameDateTable =
CALCULATETABLE (
VALUES ( 'Table'[Punch Time] ),
ALLEXCEPT ( 'Table', 'Table'[Name], 'Table'[Short Date] )
)
VAR TableAfter =
FILTER ( CurrentNameDateTable, 'Table'[Punch Time] > CurrentTime )
VAR NextTime =
MINX ( TableAfter, 'Table'[Punch Time] )
RETURN
COALESCE ( NextTime, CurrentTime ) - CurrentTime - JCKong3 years agoFrequent Visitor
Used a measurement to Sum(Table[Duration]) as the Duration column above only shows earliest and there's no selection for SUM.