Table.Buffer

Table

Buffers a table into memory, ensuring it is fully evaluated and its row order is preserved.

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

Syntax

Table.Buffer(table as table, optional options as nullable record) as table

Parameters

NameTypeRequiredDescription
tabletableYesThe table to buffer into memory.
optionsrecordNoOptional record. Use [BufferMode = BufferMode.Delayed] to defer buffering until the table is first accessed.

Return Value

tableAn in-memory copy of the table with its current row order locked in.

Remarks

Table.Buffer forces Power Query to fully evaluate a table and store it in memory. This is essential when you need to guarantee that the current row order is preserved by downstream operations, because M uses lazy evaluation and does not guarantee row order between steps by default.

The most common use case is placing Table.Buffer between a Table.Sort and a subsequent Table.Group or Table.RemoveDuplicates. Without buffering, the sort order may not be preserved, leading to unexpected results.

Be mindful of memory usage — Table.Buffer loads the entire table into memory. Avoid using it on very large datasets unless necessary. Use BufferMode.Delayed in the options record to defer buffering until the table is actually accessed, which can improve performance when the buffered table may not always be needed.

Note that Table.Buffer breaks query folding by design, since it pulls data into memory.

Examples

Example 1: Preserve sort order before grouping

let
    Sorted = Table.Sort(Sales, {"UnitPrice", Order.Ascending}),
    Buffered = Table.Buffer(Sorted)
in
    Table.Group(Buffered, "Category", {{"CheapestProduct", each List.First([Product]), type text}, {"LowestPrice", each List.Min([UnitPrice]), type number}})
Result
Category
CheapestProduct
LowestPrice
1WidgetsWidget C15
2GadgetsGadget B50
3MiscThingamajig E120

Compatibility

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