List.Buffer

D

T

The M Code Behind the Power Query M function List.Buffer

Introduction to List.Buffer

List.Buffer is a M function in Power Query that can significantly improve the performance of your data transformations. This function is used to create a buffer for a list, which means that the list will be loaded into memory and held there until the buffer is released.

One of the main advantages of using List.Buffer is that it can help reduce the number of queries that are sent to the data source. This is because List.Buffer creates a cache for the data, allowing you to perform multiple transformations on the data without having to re-query the data source.

How to Use List.Buffer

To use List.Buffer, simply call the function and pass in a list as the argument. For example, let’s say you have a table called “SalesData” that contains sales data, and you want to create a buffer for the “SalesAmount” column. You can do this by creating a new column and using the List.Buffer function, as shown below:


= Table.AddColumn(SalesData, “BufferedSalesAmount”, each List.Buffer([SalesAmount]))


In the above example, we are adding a new column called "BufferedSalesAmount" to the SalesData table. We are using the List.Buffer function to create a buffer for the "SalesAmount" column. This means that the "SalesAmount" column will be loaded into memory and held there until the buffer is released.

Benefits of Using List.Buffer

List.Buffer has several benefits that make it a popular function among Power Query users. Some of the main benefits include:

Improved Performance

As mentioned earlier, List.Buffer can significantly improve the performance of your data transformations. By creating a buffer for a list, you can reduce the number of queries that are sent to the data source and perform multiple transformations on the data without having to re-query the data source.

Reduced Memory Consumption

List.Buffer can also help reduce the amount of memory that is used by your data transformations. This is because the function only loads the data that is needed into memory, rather than loading the entire dataset into memory.

Increased Flexibility

List.Buffer can also increase the flexibility of your data transformations. This is because the function allows you to create a cache for the data, which means that you can perform multiple transformations on the data without worrying about re-querying the data source.

Best Practices for Using List.Buffer

While List.Buffer can be a powerful tool for improving the performance of your data transformations, it is important to use it wisely. Here are some best practices for using List.Buffer:

Use List.Buffer Sparingly

While List.Buffer can be a powerful tool, it should be used sparingly. This is because creating a buffer for a list can consume a lot of memory, which can impact the performance of your data transformations.

Use List.Buffer for Large Datasets

List.Buffer is most effective when used for large datasets. If you are working with small datasets, the benefits of using List.Buffer may not be as significant.

Release Buffers When No Longer Needed

It is important to release buffers when they are no longer needed. This can be done by using the List.Remove function, as shown below:


= List.Remove(BufferedSalesAmount)


List.Buffer is a powerful M function in Power Query that can significantly improve the performance of your data transformations. By creating a buffer for a list, you can reduce the number of queries that are sent to the data source, reduce memory consumption, and increase the flexibility of your data transformations. However, it is important to use List.Buffer wisely and release buffers when they are no longer needed.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)