top of page

You are learning Power Query in MS Excel

How to filter and transform data based on header information in Power Query?

There are two main approaches to filter and transform data based on header information in Power Query:

1. Filtering based on Header Values:

* Filter Rows: This is the most straightforward approach. You can filter the entire table based on specific values within the header row.
* Select the table you want to filter.
* Click "Filter Rows" under the "Home" tab.
* In the "Filter Rows" dialog box, choose the appropriate column (your header row) and enter the filtering criteria. You can use various operators like "equals," "contains," "starts with," etc.
* Click "OK" to apply the filter.

2. Transforming Data using Header Information:

* Conditional Columns: This method allows you to create new columns based on conditions defined using header information.
* Select the table you want to transform.
* Go to the "Add Column" tab.
* Click "Conditional Column."
* In the "Formula" bar, use a combination of header references and logical functions (IF, SWITCH) to define the transformation logic based on specific header values.
* Name your new column and click "OK."

Here are some additional techniques you can use:

* Text.Split: This function can be used to split the header text into separate components (e.g., splitting "Product ID" into "Product" and "ID") and use those components for further filtering or transformation.
* List.First/List.Last: If your headers contain multiple values separated by delimiters, these functions can extract the first or last value for further manipulation.
* Custom Columns: You can write custom M language code to perform complex transformations based on header information.

Remember:

* Power Query uses a formula language (M) for advanced transformations.
* You can find detailed information and examples for these functions and features in the official Microsoft documentation for Power Query M: [https://learn.microsoft.com/en-us/power-query/](https://learn.microsoft.com/en-us/power-query/)

By combining these methods, you can achieve powerful data filtering and transformation based on the information contained within your header row.

bottom of page