Forum Discussion
rogerdea
4 years agoHelper IV
DateTime difference to previous date/time
I am trying to calculate the difference in minutes between the date/time values in my table, to end up with a new column called "Diff" like in the example below. I looked at similar example...
Fowmy
4 years agoSuper User
rogerdea
Add the following DAX code in a new calculated column:
Diff in Minutes =
VAR __CURRTIME = 'Table1'[DateTime]
VAR __LASTTIME =
CALCULATE(
MAX('Table1'[DateTime]),
'Table1'[DateTime]<__CURRTIME,
REMOVEFILTERS('Table1')
)
VAR __RESULT =
DATEDIFF( __LASTTIME, __CURRTIME , MINUTE )
RETURN
__RESULT
- rogerdea4 years agoHelper IV
Thank you Fowmy
I've applied that solution to my data but it's giving strange results, and i'm not sure why. I've pasted the DAX with the actual real table names, have i applied the solution correctly?
Thanks
- rogerdea4 years agoHelper IV
I figured out why it wasn't working. I had a filter on the data which the code ignores, so the DAX is actually fine.
Is it possible to remove the REMOVEFILTERS part and have it working so that the dates dynamically change according to what filters are being used? I tried deleting that part but the calculation broke.