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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
rasknud33
Advocate I
Advocate I

Measure Performance DateTime

Hi all

 

I am having performance issues for a Measure and I hope you can help.

I have made a model that tracks the progress of a number of IT-projects.

A project can start with an estimated duration of 100 hours. When a developer works 5 hours - the remaining time will be 95 hours. The next day a developer works 10 hours and the remaining time will be 85 hours. I am tracking this progress over time.


The data looks like the following (example data from a table called History_remaining):

KeyHistory FieldHistory New Value EndHistory New Value StartHistory Old ValueHistory New Value
A-123Remaining Time 10-03-2023 15:19710
A-123Remaining Time10-03-2023 15:1908-03-2023 17:587271
A-123Remaining Time08-03-2023 17:5802-03-2023 13:5872,572
A-123Remaining Time02-03-2023 13:5802-03-2023 11:0372,7572,5
A-123Remaining Time02-03-2023 11:0301-03-2023 17:0574,2572,75
A-123Remaining Time01-03-2023 17:0522-02-2023 10:1474,7574,25
A-123Remaining Time22-02-2023 10:1417-02-2023 13:0976,7574,75
A-123Remaining Time17-02-2023 13:0914-02-2023 16:0277,2576,75
A-123Remaining Time14-02-2023 16:0213-02-2023 09:3988,2577,25
A-123Remaining Time13-02-2023 09:3930-01-2023 15:1098,2588,25
A-123Remaining Time30-01-2023 15:1020-12-2022 10:4898,7598,25
A-123Remaining Time20-12-2022 10:4807-12-2022 12:4799,598,75
A-123Remaining Time07-12-2022 12:4705-12-2022 11:0310099,5
A-123Remaining Time05-12-2022 11:0328-11-2022 14:51 100

 

I have made a measure which works as intended:

Remaining Time =

VAR measuredateDate =
MAX ( 'Dates'[Date] )
VAR RemainingHours =
CALCULATE (
SUM ( History_remaining[History New Value] ),
History_remaining[History New Value Start] <= measuredateDate,
History_remaining[History New Value End] >= measuredateDate
|| History_remaining[History New Value End] == BLANK (),
REMOVEFILTERS ( 'Dates' )
)
RETURN
RemainingHours

 

The measure 'Remaining Time' returns the follow graph:
Example 1Example 1

 

The problem I have is with performance - when all the data is in the model it takes about 35 seconds to run the measure.

I have troubleshootet and I have learned that the problem is with the [History New Value Start] and [History New Value End] columns since they are DateTime columns. If I convert DateTime to Date - the measure only takes about 3 seconds to run. However, the graph then does not compile the data in the correct way. See example below:

KeyHistory FieldHistory New Value EndHistory New Value StartHistory Old ValueHistory New Value
A-123Remaining Time 10-03-2023710
A-123Remaining Time10-03-202308-03-20237271
A-123Remaining Time08-03-202302-03-202372,572
A-123Remaining Time02-03-202302-03-202372,7572,5
A-123Remaining Time02-03-202301-03-202374,2572,75
A-123Remaining Time01-03-202322-02-202374,7574,25
A-123Remaining Time22-02-202317-02-202376,7574,75
A-123Remaining Time17-02-202314-02-202377,2576,75
A-123Remaining Time14-02-202313-02-202388,2577,25
A-123Remaining Time13-02-202330-01-202398,2588,25
A-123Remaining Time30-01-202320-12-202298,7598,25
A-123Remaining Time20-12-202207-12-202299,598,75
A-123Remaining Time07-12-202205-12-202210099,5
A-123Remaining Time05-12-202228-11-2022 100


Example 2.PNG
I suspect that this is because the measure uses the entire DateTime data to see where in the graph it should put the different numbers. When it only has the date this is getting messed up. Is there a way to get the result from example 1 but using a DAX code similar to example 2 so that the performance is improved?

I would be thankful if anyone has a suggestion to fix this and help me to improve the performance of my measure.

 

Best regards,

Rasmus

1 REPLY 1
lbendlin
Super User
Super User

Use the Performance Analyzer to grab the query for the visual, then fire up DAX Studio to examine the query plan.  Look out for the number of records column. If you see numbers in the gazillion range there you got yourself a case of the cartesian productivitis.  SQLBI.com have tons of videos on measure performance optimization.

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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.