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
BorisTPL
Frequent Visitor

How to adjust my code that it only runs under a specific condition?

Hi all, 
I have an issue calculating the TurnAround Time (TAT) for the repairs in my shop. I am calculating the TAT by summing up the amount of minutes that the Workorder had a certain status, with a filter for some specific statusses. 
My table (example for a specific workorderID) looks like this:

BorisTPL_0-1620043334306.png

 


The formula that I am using is:
Total time in minutes =

CALCULATE( SUM( WorkorderRealTime[Duration in minutes]), FILTER(WorkorderRealTime,WorkorderRealTime[WorkorderStatus_name] <> "Estimate")


And
Average time per workorder  = AVERAGEX(VALUES(WorkorderRealTime[workorderID]), [Total time in minutes].

 

This works the way it should when looking at specific workorders. For the example above it gives the correct output of 4244 minutes. 
However, when I am looking at the TAT score over time I have some issues. In the example above you can see that the repairs can take multiple days. When looking at the TAT score on a specific day, it will look at all the workorder statusses on that day and will add them up.
The problem with this, is that (with this specific example) the Duration in Minutes of status "Under repair" are counted on 23/4, while the Workorder was finished on 26/4. The TAT score of 4244 minutes should calculated for the date when it reaches the final WorkorderStatus "Done&Paid" . I'm having trouble to adjust the code so that the measure calculates the TAT score only after the workorder reaches the final status of "Done & Paid" on the right date (The last date)


So summarized: 
I want to calculate the total time of a workorder, but only when the workorder is completed, and that is has the latest timestamp that exists for that specific workorderID

 

I hope I explained it clear enough and are looking forward to a reply, thanks in advance!

1 REPLY 1
v-cazheng-msft
Community Support
Community Support

Hi @BorisTPL 

Not very clear about your needs. Could you please show your expected result in the form of table?

 

Best Regards

Caiyun Zheng

 

Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

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.