Table.ColumnsOfType

D

T

The M Code Behind the Power Query M function Table.ColumnsOfType

Understanding the Table.ColumnsOfType Function

The Table.ColumnsOfType function is one of the many M functions available in Power Query. As the name suggests, this function allows you to filter out columns of a specific data type from a table. The syntax of the Table.ColumnsOfType function is as follows:


The first argument of the function is the table from which you want to filter out columns. The second argument is the data type of the columns that you want to filter. The function returns a list of columns that match the specified data type.

Exploring the M Code Behind the Table.ColumnsOfType Function

To understand the M code behind the Table.ColumnsOfType function, let's consider an example. Suppose we have a table with the following columns:

| Name | Age | Salary |

|------|-----|--------|

| John | 25 | 5000 |

| Jane | 30 | 6000 |

| Jack | 35 | 7000 |

Suppose we want to filter out the columns that contain numeric data types. To do this, we can use the Table.ColumnsOfType function as follows:


The above code will return a list containing two columns: Age and Salary. Let’s break down the M code behind this function to understand how it works.


The above code creates a table from a list of records. Each record represents a row in the table. In this case, we have three records representing the three rows in the table.


The above code filters out columns of the numeric data type from the table. The first argument is the table created in the previous step. The second argument is the data type that we want to filter. In this case, we want to filter out columns with the numeric data type.

The Table.ColumnsOfType function is a powerful tool that allows you to easily filter out columns of a specific data type from a table in Power Query. By understanding the M code behind this function, you can leverage its power to manipulate data in a more efficient and effective manner.

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)