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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Measure to calculate time difference between the previous and current time

Hi Team,

 

Newbie here,

 

I am using below measure to calculate the difference between 2 date/time stamp per employee ID. 

 

Capture102.PNG

Result:

Capture78.PNG

 

This works well, however, I wanted to get the datediff of the current task after the next task. So in above image, START should have the value of 142 seconds because it measures the duration of the START task till the user stamps the next TASK which is BREAK.

 

So in above example I wanted to have a result like this:

Capture555.PNG

 

Kudos and Thank you so much for the help ! I will greatly appreciate it.

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @Anonymous 

Is this a measure or a calculated column?

 

Instead of  _PreviousTaskTime , create 

VAR _NextTaskTime =
CALCULATE (
    MIN ( RealTimeData[Date] ),
    ALLEXCEPT ( RealTimeData, RealTimeData[EmpName] ),
    RealTimeData[Date] > _CurrentTaskTime
)

and the use the differfence:

_NextTaskTime - _CurrentTaskTime

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

View solution in original post

2 REPLIES 2
AlB
Super User
Super User

Hi @Anonymous 

Is this a measure or a calculated column?

 

Instead of  _PreviousTaskTime , create 

VAR _NextTaskTime =
CALCULATE (
    MIN ( RealTimeData[Date] ),
    ALLEXCEPT ( RealTimeData, RealTimeData[EmpName] ),
    RealTimeData[Date] > _CurrentTaskTime
)

and the use the differfence:

_NextTaskTime - _CurrentTaskTime

Please mark the question solved when done and consider giving kudos if posts are helpful.

 Cheers 

SU18_powerbi_badge

Anonymous
Not applicable

Hi @AlB ,

 

Whoaa ! That's pretty fast. Thanks for the solution. I just retweaked my variable _PreviousTaskTime to change from MAX to MIN and then the correct output shows up.

 

Thank you so much!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors