Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Potential bug in Power Query's Table.Skip function. Tested in the following:
When removing rows from the top of a table (for example, remove the top 10 rows) using the Table.Skip function, the first 10 rows are deleted as expected.
However, if the step before the "remove 10 rows from the top" is a sort function using Table.Sort, the results are wildly unpredictable. Various unrelated rows from the table are deleted and the result is resorted by what appears to be total randomness.
If you sort by multiple criteria (ex: sometimes sorting by two columns, other times by three or more), the Table.Skip function works as expected, removing the top N rows from the table.
Removing the Table.Sort step makes the Table.Skip function work properly.
To my expectation: the Table.Skip using a number as the argument should remove the First N rows regardless of the content. The content should have no bearing on which rows get removed. It should be the First N no matter what. What am I missing here?
The source table is only 360 rows.
According to officiel documentation : "Buffers a table in memory, isolating it from external changes during evaluation. Buffering is shallow. It forces the evaluation of any scalar cell values, but leaves non-scalar values (records, lists, tables, and so on) as-is."
I faced this issue before applying a Table.Distinct.
My assumptions is because of some internal under the hood optimization, PQ is applying the triage (Table.Distinct, Table.Skip, ...) before applying the sorting operation.
About the fact that this is more a workaround, I follow you on this. In my case (few lines, like you) it is ok and work as expected so I didn't dig deeper !
I just found this while searching another tyhing !
https://learn.microsoft.com/en-us/power-query/common-issues#preserving-sort
You might assume that if you sort your data, any downstream operations will preserve the sort order.
For example, if you sort a sales table so that each store's largest sale is shown first, you might expect that doing a "Remove duplicates" operation will return only the top sale for each store. And this operation might, in fact, appear to work. However, this behavior isn't guaranteed.
Because of the way Power Query optimizes certain operations, including skipping them or offloading them to data sources (which can have their own unique ordering behavior), sort order isn't guaranteed to be preserved through aggregations (such as Table.Group), merges (such as Table.NestedJoin), or duplicate removal (such as Table.Distinct).
There are a number of ways to work around this. Here are a few suggestions:
hi,
I faced the same issue. Just use Table.Buffer() arround your Table.Sort; for example:
#"sortedArray" = Table.Buffer(Table.Sort(#"previousStep",{{"column", Order.Descending}})),
That worked...
...but can you explain what the Table.Buffer is doing to make the sort perform differently? The average PQ user is NOT going to think to do this. I would still consider it a bug with a workaround. Thanks, in advance.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.