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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
martinhyy
Frequent Visitor

How to calculate the duration in M or other language

Hi community,

 

This is my first post. I'm just wondering how to use any language to track the time that is used to query the data.

 

Concretely, I've got a query purely in MDX, when I choose a certain date range and load it directly to Power BI, it takes about 7mins to finish the loading (by looking at the clock). However I would like to know the exact time that is spent on the loading process.

 

I imagine there should be some kind of code

 

let 
   
    start_Time = DateTime.LocalNow()
   
    source = /*my MDX code here*/

    duration = DataTime.LocalNow() - start_Time

in
   
    duration

The code above always gives me a duration that is really close to 0 which probably means it didn't run the source part? Any ideas how I can make this correction?

 

Thanks

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee


Measuring execution time in Power Query is not easy, especially because of the answer to your last question: no, execution order is not guaranteed from top to bottom. Instead, Power Query uses lazy evaluation, i.e. code won't be evaluated until it is actually required.

You may best be helped by this blog from Chris Webb in which he explains how to use Diagnostics.Trace to measure execution time.


 

See the reply from @MarcelBeug in Power Query - log start and end time of running a query

View solution in original post

1 REPLY 1
Eric_Zhang
Employee
Employee


Measuring execution time in Power Query is not easy, especially because of the answer to your last question: no, execution order is not guaranteed from top to bottom. Instead, Power Query uses lazy evaluation, i.e. code won't be evaluated until it is actually required.

You may best be helped by this blog from Chris Webb in which he explains how to use Diagnostics.Trace to measure execution time.


 

See the reply from @MarcelBeug in Power Query - log start and end time of running a query

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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