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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
ronaldbalza2023
Continued Contributor
Continued Contributor

DAX Query refactor

Hi everyone, I have a dax query that calculates the jobturnaround time. However, it took 7191ms to load using the matrix table. Could someone help out to refactor it? Thanks! 🙂

Here's the measure:

 

Job Turnaround Time (Days) = 
CALCULATE (
    AVERAGE ( Jobs[Days Between Start Date & Completed Date] ),
    USERELATIONSHIP ( 'Date'[Date], Jobs[Jobs Job Completed Date] ),
    USERELATIONSHIP ( 'Unique Staff'[StaffID], Jobs[Job Manager ID] ),
    USERELATIONSHIP ( Clients[ID], Jobs[Jobs Job Client ID])
) + 0

 

 Here's the performance analyzer snapshot.

ronaldbalza2023_0-1628650524775.png

 

1 ACCEPTED SOLUTION

Hi,

If we want to see only those line items in the visual where the measure returns a non 0 value, then why are we even using an IF() or a COALESCE().  Why not just use this

=CALCULATE(AVERAGE(Jobs[Days Between Start Date & Completed Date]),USERELATIONSHIP(Jobs[Jobs Job Completed Date],'Date'[Date]),USERELATIONSHIP(Jobs[Job Manager ID],'Unique Staff'[StaffID]),USERELATIONSHIP(Jobs[Jobs Job Client ID],Clients[ID]))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Is this measure any faster:

Job Turnaround Time (Days) = 
COALESCE(CALCULATE(AVERAGE(Jobs[Days Between Start Date & Completed Date]),USERELATIONSHIP(Jobs[Jobs Job Completed Date],'Date'[Date]),USERELATIONSHIP(Jobs[Job Manager ID],'Unique Staff'[StaffID]),USERELATIONSHIP(Jobs[Jobs Job Client ID],Clients[ID])),0)

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

not really. I guess the bottleneck was when I applied filter into it (removing zeros). There comes the slow matrix. 

ronaldbalza2023_0-1628655303734.png

ronaldbalza2023_1-1628655484128.png

 

 

Hi,

If we want to see only those line items in the visual where the measure returns a non 0 value, then why are we even using an IF() or a COALESCE().  Why not just use this

=CALCULATE(AVERAGE(Jobs[Days Between Start Date & Completed Date]),USERELATIONSHIP(Jobs[Jobs Job Completed Date],'Date'[Date]),USERELATIONSHIP(Jobs[Job Manager ID],'Unique Staff'[StaffID]),USERELATIONSHIP(Jobs[Jobs Job Client ID],Clients[ID]))

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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