Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
EZiamslow
Helper III
Helper III

calculate 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 column, I have multiple tool IDs. My end goal is to find out average each tool down time for weekly, monthly, and quarterly.

 

Thank you for helping!

 

ToolDateTimeAvailabilityDownTime
AAA8/20/2022 23:08D 
AAA8/20/2022 22:08D 
AAA8/20/2022 18:45U1:33
AAA8/20/2022 17:12D 
AAA8/20/2022 14:08U18:57
AAA8/19/2022 19:11D
AAA8/18/2022 21:06U 
AAA8/18/2022 20:15U2:00
AAA8/18/2022 19:18D
AAA8/18/2022 18:15D

 

ToolDownTime.JPG

 

ToolDownTime2.JPG

Regards,
Eddie

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@EZiamslow 

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)))
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Anonymous
Not applicable

Hi @EZiamslow ,

Based on the description, after getting data, selecting transform before Loading.

vjiewumsft_0-1721869290615.png

Selecting custom column and adding a year column.

Date.Year([Date]))

vjiewumsft_1-1721869301848.png

Selecting custom column, add a month column.

Date.Month([Date])

vjiewumsft_2-1721869317523.png

Then, selecting the desired year, reducing the number of data.

vjiewumsft_3-1721869343430.png

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.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @EZiamslow ,

Based on the description, after getting data, selecting transform before Loading.

vjiewumsft_0-1721869290615.png

Selecting custom column and adding a year column.

Date.Year([Date]))

vjiewumsft_1-1721869301848.png

Selecting custom column, add a month column.

Date.Month([Date])

vjiewumsft_2-1721869317523.png

Then, selecting the desired year, reducing the number of data.

vjiewumsft_3-1721869343430.png

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.

@Anonymous 

which DAX formula are you referring to?

Anonymous
Not applicable

Hi @EZiamslow ,

Reducing the number of rows through the power query editor before loading the data. Then, using the @ryan_mayu  provide Dax formula. It should help.

 

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
Super User

@EZiamslow 

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)))
 
11.PNG




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu 

I have 600k rows and it crashed my Desktop app. Is there other options to make it work?

so far I don't have another better solution for this. Let's see if anyone else can help on this.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.