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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount 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
Community Champion
Community Champion

@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!:
DAX For Humans

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!:
DAX For Humans

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Kudoed Authors