Forum Discussion
Anonymous
7 years agoNot applicable
Calculate time difference by matching ids
Hi, im trying to do something like this
When id matchs, it calculates the time difference with the previous record
I think in something with earlier function and filter but i couldnt make it work
Any ideas?
Thanks!
EARLIER refers to the filter context, not to the date/position in table
try thisColumn = VAR _id = 'Table'[id] VAR _created = 'Table'[created] VAR _previousDate = CALCULATE(MAX('Table'[created]),FILTER(ALL('Table'),'Table'[id] = _id && 'Table'[created] < _created)) VAR _handleBlanks = IF(ISBLANK(_previousDate),_created,_previousDate) RETURN _created-_handleBlanks
2 Replies
- Stachu
Community Champion
EARLIER refers to the filter context, not to the date/position in table
try thisColumn = VAR _id = 'Table'[id] VAR _created = 'Table'[created] VAR _previousDate = CALCULATE(MAX('Table'[created]),FILTER(ALL('Table'),'Table'[id] = _id && 'Table'[created] < _created)) VAR _handleBlanks = IF(ISBLANK(_previousDate),_created,_previousDate) RETURN _created-_handleBlanks- AnonymousNot applicable
Thanks for the help!
It is working