Forum Discussion
EZiamslow
Helper III
2 years agocalculate difference in date/time based on multiple up and down time
Hi, What would be the best option to calculate tool down time between the earliest D=down and earliest U=Up time for each instance? DownTime is the result that I'm trying to work it out. In Tool...
- 2 years ago
you can try this
Column =VAR _last=maxx(FILTER('Table','Table'[DateTime]<EARLIER('Table'[DateTime])),'Table'[DateTime])VAR _lasta=maxx(FILTER('Table','Table'[DateTime]=_last),'Table'[Availability])VAR _last2=maxx(FILTER('Table','Table'[DateTime]<EARLIER('Table'[DateTime])&&'Table'[Availability]="U"),'Table'[DateTime])VAR _lasttime=minx(FILTER('Table','Table'[DateTime]>_last2),'Table'[DateTime])return if ('Table'[Availability]="U" && _lasta="U", blank(), if('Table'[Availability]="U" && ISBLANK(_lasttime),'Table'[DateTime]-max('Table'[DateTime]),if('Table'[Availability]="U",'Table'[DateTime]-_lasttime))) - Anonymous2 years ago
Hi EZiamslow ,
Based on the description, after getting data, selecting transform before Loading.
Selecting custom column and adding a year column.
Date.Year([Date]))Selecting custom column, add a month column.
Date.Month([Date])Then, selecting the desired year, reducing the number of data.
Closing and applying.
Then, using the DAX formula provided above.
Best Regards,
Wisdom Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryan_mayu
Super User
2 years agoyou can try this
Column =
VAR _last=maxx(FILTER('Table','Table'[DateTime]<EARLIER('Table'[DateTime])),'Table'[DateTime])
VAR _lasta=maxx(FILTER('Table','Table'[DateTime]=_last),'Table'[Availability])
VAR _last2=maxx(FILTER('Table','Table'[DateTime]<EARLIER('Table'[DateTime])&&'Table'[Availability]="U"),'Table'[DateTime])
VAR _lasttime=minx(FILTER('Table','Table'[DateTime]>_last2),'Table'[DateTime])
return if ('Table'[Availability]="U" && _lasta="U", blank(), if('Table'[Availability]="U" && ISBLANK(_lasttime),'Table'[DateTime]-max('Table'[DateTime]),if('Table'[Availability]="U",'Table'[DateTime]-_lasttime)))