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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
skumar0105
Helper II
Helper II

How to calculate machine running hours of each day

Hi,

I have a data with columns "total Machine running hours', 'Machine ON/OFF status', 'Date' & 'Time'.

data is refreshed at every 30 mins interval, i want to calculate total running time of previous day or live.

 

Can anyone help.

 

Regards

Satish 

1 ACCEPTED SOLUTION

Hi @skumar0105 

 

You can add a calculated column with below DAX. 

Running Hours = 
VAR MaxHours = CALCULATE(MAX('Table'[CHILLER_U9_COMP_RUNNING_TIME]),ALLEXCEPT('Table','Table'[Date]))
VAR MinHours = CALCULATE(MIN('Table'[CHILLER_U9_COMP_RUNNING_TIME]),ALLEXCEPT('Table','Table'[Date]))
VAR MaxTime = CALCULATE(MAX('Table'[Time]),ALLEXCEPT('Table','Table'[Date]))
RETURN
IF('Table'[Time] = MaxTime, MaxHours - MinHours, BLANK())

vjingzhang_0-1657782486549.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

9 REPLIES 9
skumar0105
Helper II
Helper II

Hi Everyone,

I am still struck at this issue, prompt response will be appreciable.

 

Regards
Satish

Greg_Deckler
Super User
Super User

@skumar0105 Seems like a variation of MTBF. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler my dataset looks like this

skumar0105_1-1657209516144.png

can you suggest any other query

 

Regards

Satish

@skumar0105 Right, so it depends on what you are trying to do exactly and what the data is. If the "CHILLER" column is your running total time and I'm guessing it is in minutes or hours or ? Anyway. If you want the current day's total running time then I am guessing that you could take the MAX "CHILLER" for TODAY. Also get the MIN "CHILLER" for TODAY. Subtract the two.

 

For previous day, TODAY() - 1.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler can you write syntax to find out daily running time, i am new to this field.

BTW the Chiller running time is in hours.

Simply, i want the output as below table:

ON_OFF_STATUS

CHILLER_U9_COMP_

RUNNING_TIME

TimeDateDuration of the Chiller Run Today (hrs)
ON52647.50010:00:0007.07.20221
OFF52647.50009:00:0007.07.2022 
ON52646.50008:00:0007.07.2022 
OFF52646.50023:55:0006.07.20221.50
ON51646.00023:05:0006.07.2022 
OFF51646.00023:00:0006.07.2022 
ON51645.00022:00:0006.07.2022 

 

Please ignore formatting.

 

 

Regards

Satish

Hi @skumar0105 

 

You can add a calculated column with below DAX. 

Running Hours = 
VAR MaxHours = CALCULATE(MAX('Table'[CHILLER_U9_COMP_RUNNING_TIME]),ALLEXCEPT('Table','Table'[Date]))
VAR MinHours = CALCULATE(MIN('Table'[CHILLER_U9_COMP_RUNNING_TIME]),ALLEXCEPT('Table','Table'[Date]))
VAR MaxTime = CALCULATE(MAX('Table'[Time]),ALLEXCEPT('Table','Table'[Date]))
RETURN
IF('Table'[Time] = MaxTime, MaxHours - MinHours, BLANK())

vjingzhang_0-1657782486549.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

@v-jingzhang 

It worked for me.

Thank you so much Sir.

 

@v-jingzhang 

It worked for me.

Thank you so much Sir.

 

Vijay_A_Verma
Super User
Super User

You will need to post some sample/dummy data. Refer to this - How to provide sample data in the Power BI Forum - https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors