Table.StopFolding

Table

Returns a new table that prevents any further query folding, forcing local evaluation.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Table.StopFolding(table as table) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table to prevent from further query folding.

Return Value

tableA table that is identical to the input but will not fold subsequent operations to the data source.

Remarks

Table.StopFolding explicitly breaks the query folding chain at the point where it is applied. Any Power Query steps after Table.StopFolding are evaluated locally by the Power Query engine rather than being translated into a source-native query (such as SQL or OData $filter). The table's data and column structure are unchanged — only the execution model is affected.

Use Table.StopFolding when: - A downstream step is incompatible with folding (e.g., a custom M function or a complex transformation) and the engine would otherwise generate an incorrect or overly broad native query to compensate. - Query folding is producing unexpected results from the data source (e.g., the source interprets a folded filter differently than M would), and you need to force local evaluation for correctness. - You are debugging query folding behavior and want to definitively mark where the fold boundary should be.

Gotcha: Breaking folding means all rows must be transferred from the data source to the Power Query engine before local operations begin. On large tables this can be extremely slow — use Table.StopFolding judiciously and as close to the end of the pipeline as possible. In many cases, Table.Buffer is a better choice when the goal is to cache a snapshot of the data rather than to control folding semantics.

Examples

Example 1: Force local evaluation after a non-foldable step in a SQL pipeline

let
    Source   = Sql.Database("myserver", "SalesDB"),
    Orders   = Source{[Schema="dbo", Item="Orders"]}[Data],
    Stopped  = Table.StopFolding(Orders),
    Enriched = Table.AddColumn(Stopped, "RevenueCategory",
                   each if [Amount] > 500 then "High" else "Low", type text)
in
    Enriched
Applied Steps

The final output — adds a local RevenueCategory column computed by M; because folding was stopped, this conditional logic runs in memory and is never sent to the SQL engine.

Note
1RevenueCategory is computed locally; no SQL translation is attempted for this column.

Example 2: Prevent folding when a data source misinterprets a filter

let
    Source   = Sql.Database("myserver", "CRM"),
    Contacts = Source{[Schema="dbo", Item="Contacts"]}[Data],
    Local    = Table.StopFolding(Contacts),
    Filtered = Table.SelectRows(Local, each Text.Lower([LastName]) = "smith")
in
    Filtered
Applied Steps

The final output — applies a case-insensitive last-name filter in M after all rows have been fetched locally, guaranteeing M's semantics rather than the source's case-sensitive comparison.

Note
1Filter is applied locally by M after all rows are fetched, ensuring case-insensitive matching.

Example 3: Use Table.Buffer as a folding alternative when caching is the real goal

let
    Source  = Sql.Database("myserver", "Analytics"),
    Sales   = Source{[Schema="dbo", Item="Sales"]}[Data],
    // Use Table.Buffer to materialize and cache, preventing repeated source queries:
    Buffered = Table.Buffer(Sales),
    Joined   = Table.NestedJoin(Buffered, "CustomerID", OtherTable, "ID", "Matches")
in
    Joined
Applied Steps

The final output — performs a nested join between the buffered Sales table and OtherTable on matching IDs; since Sales is already in memory, no additional source queries are issued.

Note
1Table.Buffer materializes Sales once; subsequent operations read from memory rather than re-querying the source.

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks