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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors