Table.Buffer
TableBuffers a table into memory, ensuring it is fully evaluated and its row order is preserved.
Syntax
Table.Buffer(table as table, optional options as nullable record) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The table to buffer into memory. |
options | record | No | Optional record. Use [BufferMode = BufferMode.Delayed] to defer buffering until the table is first accessed. |
Return Value
table — An 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}})Category | CheapestProduct | LowestPrice | |
|---|---|---|---|
| 1 | Widgets | Widget C | 15 |
| 2 | Gadgets | Gadget B | 50 |
| 3 | Misc | Thingamajig E | 120 |