Forum Discussion
Time difference between date time values in same column based on a value in a different column
- 6 years ago
Hi Anonymous ,
Here is the pbix PBIX
I put both columns in so that you have your choice, the second column only shows in the last row of the user. The difference between the measure and the column at the high level, is that with a measure, the engine does not have row context, whereas in the table it does. (It knows which row it is operating on.) Therefore it was just a matter of dropping MAX().
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
Hi Anonymous
What is the difference between the two tables?
Nathaniel
- Nathaniel_C6 years agoCommunity Champion
Hi Anonymous ,
If I understand correctly this is what you are looking as an output?
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniellapse Secs Calc = VAR _curTime = MAX ( TimeElapse[Date Time Start] ) VAR _pasttime = CALCULATE ( MAX ( TimeElapse[Date Time Start] ), TimeElapse[Date Time Start] < _curTime, ALLEXCEPT ( TimeElapse, TimeElapse[User], TimeElapse[Function] ) ) VAR _dif = DATEDIFF ( _pasttime, _curTime, SECOND ) RETURN _dif
- Nathaniel_C6 years agoCommunity Champion
Hi Anonymous
Or with zeros.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
NathanielElapse Secs Calc = VAR _curTime = MAX ( TimeElapse[Date Time Start] ) VAR _pasttime = CALCULATE ( MAX ( TimeElapse[Date Time Start] ), TimeElapse[Date Time Start] < _curTime, ALLEXCEPT ( TimeElapse, TimeElapse[User], TimeElapse[Function] ) ) VAR _dif = IF(ISBLANK(_pasttime), 0 ,DATEDIFF ( _pasttime, _curTime, SECOND )) RETURN _dif- Nathaniel_C6 years agoCommunity Champion
Hi Anonymous ,
Here is the solution with only the final value showing for each User and Function.
Only latest value = VAR _calc = [Cummulative] VAR _maxDate = CALCULATE ( MAX ( TimeElapse[Date Time Start] ), ALLEXCEPT ( TimeElapse, TimeElapse[User], TimeElapse[Function] ) ) RETURN IF ( MAX ( TimeElapse[Date Time Start] ) = _maxDate, [Cummulative], 0 )
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel
- Anonymous6 years agoNot applicable
Hi Nathaniel_C ,
I just imported my example data into a new file and ran your function on it but my results do not match to what you had.
- Nathaniel_C6 years agoCommunity Champion
Hi Anonymous ,
Try it as a measure, not a calculated column. Looking at your first picture that is what i built it for. Put the first 5 columns on a table, then add the measure.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel