Query Diagnostics0%

Query Diagnostics

Beginner12 min read•Updated: Jul 11, 2026
Study MaterialsCheatsheet

Query Diagnostics & Query Folding in Power Query

When Power BI reports take tens of minutes to refresh or when visual interactions feel slow, the root cause is frequently an un-optimized Power Query ETL transformation. To debug data extraction performance, intermediate developers utilize Query Diagnostics and master Query Folding.


1. What is Query Folding? (The Silver Bullet of ETL)

Query Folding is the ability of Power Query to translate user transformation steps (filtering, grouping, joining, column selection) into a single native query (such as SQL) and execute it on the source database server:

Visual Architecture & Process Flow

How data and code flow step-by-step

Flowchart
Step 1
1. Filter: Country = "India" ---
Step 2
SELECT CustomerID, City, SUM
Sales

Why Query Folding is Critical:

  • The database server (SQL Server, Oracle, Snowflake) performs the heavy filtering and aggregation using its indexed hardware.
  • Only the compact, aggregated final result is sent over the network to Power BI.
  • Enables Incremental Refresh in the Power BI Service!

2. Checking if a Step is Folding

  1. 1
    In Power Query Editor, right-click on the last applied step in the Applied Steps list.
  2. 2
    Inspect the View Native Query option:
  • Enabled (Clickable): The step folds! You can click it to view the exact SQL statement generated.
  • Disabled (Grayed Out): Query folding has broken! Power Query was forced to download the entire un-filtered raw dataset into local memory to evaluate that step.
Output
Common Steps that PRESERVE Query Folding:
[X] Filter rows (WHERE clause)
[X] Select or remove columns (SELECT column list)
[X] Group By and Aggregations (GROUP BY / Aggregate functions)
[X] Inner joins with other folded queries (INNER JOIN)
 
Common Steps that BREAK Query Folding:
[!] Complex custom M functions
[!] Changing data types across non-compatible formats
[!] Running Python or R scripts in Power Query
[!] Index column insertion

3. Running Query Diagnostics

To trace which exact step is taking the most CPU time or network I/O:

  1. 1
    In Power Query Editor, go to the Tools ribbon tab.
  2. 2
    Click Start Diagnostics.
  3. 3
    Perform the query refresh.
  4. 4
    Click Stop Diagnostics.
  5. 5
    Power Query automatically generates diagnostic result tables detailing query duration, resource usage, and data source activity.

Interactive Quiz

Multiple Choice Questions

Question 1
What is Query Folding in Microsoft Power BI?
Question 2
How can an analyst quickly verify if an applied step in Power Query is successfully folding?
Question 3
Which of the following operations is most likely to BREAK Query Folding in Power Query?
Question 4
Why is Query Folding an absolute prerequisite for configuring Incremental Refresh in the Power BI Service?
Question 5
Where do you find the "Start Diagnostics" and "Stop Diagnostics" buttons in Power Query Editor?

Next Lesson

Best Practices for Report Performance

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

PrevNext