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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ZB_tech
Regular Visitor

Calculation of Sustainability in duration for the following data

ZB_tech_0-1747742744107.png

In this i need the sustainability time in minutes for each damper position. i.e., if my damper position 60  is from 07:09 and it changes to 0 at 07:18 then my sustainability time should be 8 minutes. How can i acheive this? Please share ASAP.

 

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@ZB_tech 

Create a new calculated column to calculate the time difference between each row. 

DAX
TimeDifference =
VAR CurrentTime = 'Table'[Time]
VAR PreviousTime =
CALCULATE(
MAX('Table'[Time]),
FILTER(
'Table',
'Table'[Time] < CurrentTime
)
)
RETURN
IF(
ISBLANK(PreviousTime),
0,
DATEDIFF(PreviousTime, CurrentTime, MINUTE)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

pankajnamekar25
Super User
Super User

Sort the table by Time in ascending order.

Add an Index Column (called Index).

  Add a custom column to track when a new segment starts:

Go to Add Column > Custom Column, name it Segment Key,

if [Index] = 0 then 0

else if [Damper Position] = #"Previous Step"[Damper Position]{[Index]-1} then null

else [Index]

  Fill down the Segment Key column to assign segment start points across rows with the same damper position.

Group by Segment Key

Add columns

Min Time = Minimum of Time

Max Time = Maximum of Time

Damper Position = All Rows → Extract the first value from Damper Position


Add a custom column to calculate duration in minutes:

powerquery

Duration.Minutes([Max Time] - [Min Time])

 Remove unnecessary columns and rename as needed.

 

 

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

View solution in original post

2 REPLIES 2
pankajnamekar25
Super User
Super User

Sort the table by Time in ascending order.

Add an Index Column (called Index).

  Add a custom column to track when a new segment starts:

Go to Add Column > Custom Column, name it Segment Key,

if [Index] = 0 then 0

else if [Damper Position] = #"Previous Step"[Damper Position]{[Index]-1} then null

else [Index]

  Fill down the Segment Key column to assign segment start points across rows with the same damper position.

Group by Segment Key

Add columns

Min Time = Minimum of Time

Max Time = Maximum of Time

Damper Position = All Rows → Extract the first value from Damper Position


Add a custom column to calculate duration in minutes:

powerquery

Duration.Minutes([Max Time] - [Min Time])

 Remove unnecessary columns and rename as needed.

 

 

 

Thanks,
 Pankaj Namekar | LinkedIn

If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.

bhanu_gautam
Super User
Super User

@ZB_tech 

Create a new calculated column to calculate the time difference between each row. 

DAX
TimeDifference =
VAR CurrentTime = 'Table'[Time]
VAR PreviousTime =
CALCULATE(
MAX('Table'[Time]),
FILTER(
'Table',
'Table'[Time] < CurrentTime
)
)
RETURN
IF(
ISBLANK(PreviousTime),
0,
DATEDIFF(PreviousTime, CurrentTime, MINUTE)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.