Ravi Chandu Edru/ videos

Tiny Fixes · 5 of 10

Why is my Power BI refresh so slow? Query folding fix

Oct 25, 2026 · 1:39 · Short

In this video

I wanted the last 10 orders from a 20,000,000-row SQL Server table. On my laptop the refresh took over 3 minutes. After one small change in Power Query: under a second. Same 10 rows.

Why: I sorted ascending, then used Keep Bottom Rows. SQL Server has TOP but no way to ask for bottom rows, so that step can't fold (it can't be handed to the database). Power Query asked for all 20,000,000 rows and kept 10 itself. SQL Server's own query stats showed the request: select ... from Sales order by OrderId, 20,000,000 rows.

The fix, recorded live in Power BI Desktop, in 3 steps:

  1. Change the sort to descending (Order.Ascending becomes Order.Descending), so the last 10 orders are on top.
  2. Delete the Kept bottom rows step.
  3. On the Home tab: Keep Rows, Keep Top Rows, type 10. (Power BI names the new step Kept First Rows.)

Same 10 orders, but now Power BI sends select top 10 ... order by OrderId desc, and only 10 rows come back.

How to check any step on a database source: right-click it. If View Native Query is greyed out, that step can't be turned into SQL, so Power BI downloads every row. Before the fix, Kept bottom rows shows it greyed out; after the fix, Kept First Rows shows it again, with the exact query (select top 10).

One limit: CSV and Excel files don't support folding at all. Power Query does that work itself.

Measured on my laptop with the database on the same machine; your timings will differ, the row counts won't.

Docs:
Query folding examples (this exact case): learn.microsoft.com/power-query/query-folding-examples

Query folding basics: learn.microsoft.com/power-query/query-folding-basics

Read the transcript

Press a time to play from there.

On my laptop, this refresh took over 3 minutes. After one small fix: under a second. Same 10 rows. Here's why. To get the last 10 orders, I sorted, then kept the bottom 10 rows. But SQL Server can only ask for the top rows, not the bottom.

So that step can't fold: it can't be handed to the database. Power Query pulled all 20,000,000 rows, just to keep 10. The fix, in 3 steps. 1: change the order to descending, so the last 10 orders are on top. 2: delete the Kept bottom rows step.

3: on the Home tab, click Keep Rows, then Keep Top Rows, and type 10. Same 10 orders. But now Power BI sends one small query, select top 10, and only 10 rows come back. How can you tell? Right-click the step. Before the fix, on Kept bottom rows, View Native Query is greyed out: this step can't be sent to the database.

After the fix, on Kept First Rows, it's back, and it shows the exact query. One limit: CSV and Excel files don't support folding at all. Power Query always does that work itself. Let the database do the work, and check your last step. Found this useful?

Hit like and subscribe for more fixes that save your reports. See you in the next one!