<!-- https://learnsql.cpetoday.com/functions/m/list-buffer -->
# List.Buffer

Language: Power Query M
Category: List: transform and filter
Syntax: List.Buffer(list)
Summary: Loads a list into memory once, so later steps reuse the same values instead of recalculating them.
Returns: The same list, held in memory.
Level: Advanced
Related: List.Transform, List.Sort, List.Accumulate, List.Distinct, List.Sum

## What it does
Power Query normally re-evaluates a step each time something refers to it. List.Buffer tells it to evaluate the list once and keep the result in memory. Use it when the same list feeds several calculations, or when a list is expensive to make, such as one built with List.Accumulate or read from a slow file.

## Syntax and arguments
- `list`: the list to hold in memory. Nothing else changes.

## Example
A close checklist uses the same list of approved vendor codes in three different checks. Buffering the list means it is read once.

```powerquery
let
    ApprovedVendorCodes = {"V-1001", "V-1002", "V-2044", "V-1001"},
    Codes = List.Buffer(List.Distinct(ApprovedVendorCodes)),
    CheckA = List.Count(Codes),
    CheckB = List.Select(Codes, each Text.StartsWith(_, "V")),
    CheckC = List.Contains(Codes, "V-1001")
in
    CheckC
```

Each check uses the same stored list. `CheckC` is true if the code exists in the approved list. Without the buffer, the distinct step could run three times.

## Example: a second, different use
Buffering a sorted list that a running total depends on, so the sort does not repeat for every row.

## Things to watch
- Buffering uses memory. Do not buffer a very large list or a whole big table without a reason.
- A buffered list is a snapshot of the source at the time it was read. It does not refresh until the query does.
- Buffering stops query folding. Filters and selections placed after a buffer run in the workbook, not on the database.
- Table.Buffer is the table version. Use it with care, and only after the steps that can fold.

## In business terms
Reference lists such as approved vendors, valid account codes or the chart of accounts are read many times in a close. Buffering keeps the workbook responsive and makes the query behave the same way on every check.
