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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rosscortb
Post Patron
Post Patron

Help with days hrs and mins formatting

Hello

In the attached I have tried to work out the approval times between each stage in column Step Last Routed.

 

In the format column it should show in days min and hrs but its putting days to 30 in some cases when it should be 0.

Also, the Approval Time is not displaying the correct date and time from the previous row.

 

Also, for any step last routed that has "Job Requisition Creation" in Step Description, then it should be blank in the times as this the start of the process in each job req.

 

Any help would be appreciated.  Attachment 

 

Thanks

Ross

3 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@rosscortb 

Hope this link will help you: https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-usi...

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

tex628
Community Champion
Community Champion

This is abit more complacted than one might think, you need to calculate the days, hour and minutes individually. Take a look at the attached file:

Also, how is the calculation supposed to handle if it's more than 99 days? 

Br,
J


Connect on LinkedIn

View solution in original post

mahoneypat
Employee
Employee

The "30" is coming from the date component of the result of subtracting the two dates (12/30/1899).  Duration stuff is usually easier in the query editor.  However, it can be done in DAX too (with more code).  I couldn't refresh against your source data to modify your query directly, so here is the DAX approach.  Here are two column expressions to get your desired result I believe.  You may want to change the approach on the second one to just return the cycle time in days/hours/min in decimal form so you can use it in calculations (instead of this text column).

 

Prev Step DateTime =
VAR thisID = Demo[Category ID]
RETURN
CALCULATE (
MIN ( Demo[Step Last Routed] ),
ALLEXCEPT (
Demo,
Demo[Category ID],
Demo[Job Req ID]
),
Demo[Category ID] = thisID - 1
)

 

Time Diff = var thisstep = Demo[Step Last Routed]
var laststep = Demo[Prev Step DateTime]
var diff = DATEDIFF(laststep, thisstep, MINUTE)
var days = ROUNDDOWN(diff/24/60,0)
var hours = ROUNDDOWN((diff - days*60*24)/60, 0)
var minutes = ROUNDDOWN(diff - days*60*24 - hours*60, 0)
return if(Demo[Step Description] = "Job Requisition Creation", BLANK(), days&":"&hours&":"&minutes)




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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
v-shex-msft
Community Support
Community Support

Hi @rosscortb,

Did these replies help with your score? If this is a case, you can consider accepting a suitable one to help others who have a similar requirement to find it more quickly.
If all of these not help, you can post here with detailed information to help us clarify your scenario.
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
mahoneypat
Employee
Employee

The "30" is coming from the date component of the result of subtracting the two dates (12/30/1899).  Duration stuff is usually easier in the query editor.  However, it can be done in DAX too (with more code).  I couldn't refresh against your source data to modify your query directly, so here is the DAX approach.  Here are two column expressions to get your desired result I believe.  You may want to change the approach on the second one to just return the cycle time in days/hours/min in decimal form so you can use it in calculations (instead of this text column).

 

Prev Step DateTime =
VAR thisID = Demo[Category ID]
RETURN
CALCULATE (
MIN ( Demo[Step Last Routed] ),
ALLEXCEPT (
Demo,
Demo[Category ID],
Demo[Job Req ID]
),
Demo[Category ID] = thisID - 1
)

 

Time Diff = var thisstep = Demo[Step Last Routed]
var laststep = Demo[Prev Step DateTime]
var diff = DATEDIFF(laststep, thisstep, MINUTE)
var days = ROUNDDOWN(diff/24/60,0)
var hours = ROUNDDOWN((diff - days*60*24)/60, 0)
var minutes = ROUNDDOWN(diff - days*60*24 - hours*60, 0)
return if(Demo[Step Description] = "Job Requisition Creation", BLANK(), days&":"&hours&":"&minutes)




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

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


tex628
Community Champion
Community Champion

This is abit more complacted than one might think, you need to calculate the days, hour and minutes individually. Take a look at the attached file:

Also, how is the calculation supposed to handle if it's more than 99 days? 

Br,
J


Connect on LinkedIn
Fowmy
Super User
Super User

@rosscortb 

Hope this link will help you: https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-usi...

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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