Introduction

Power BI offers with the Power Query Editor a powerful tool for cleaning and transforming data. One important part of data preparation is filtering your data. Filtering enables you to sort out irrelevant data and to reduce the amount of data. One important type of filtering is custom filtering. Custom filtering is necessary if your filter requirements cannot be met by the pre-defined filters in Power Query. In this case, you can code your own filter condition as Power Query M code. In this tutorial, we will show you how to create and apply custom filters in Power Query.

Data

The data for this tutorial comes from an Excel file. In the following tutorial, we have shown how to import Excel into Power BI:

Power BI - Import Data from Excel file
Introduction In this tutorial, we want to import Data from a Excel file into Power BI. This can be easily done in the Power BI Desktop interface. Data Source Our data source is the Excel file student. The file contains the following data: Power BI Desktop In the following, we

We have loaded the data into Power BI but we haven't executed any transformations on the data. The data looks as follows:

Open Power Query Editor

First, we open the Power Query Editor by clicking on "Transform Data":

This takes us to the Power Query Editor interface:

💡
All steps that are performed are displayed on the right-hand sidebar. You have the opportunity to undo steps at any time.

Create Custom Filter

Now, let's explore how to create a custom filter in Power Query. In the following example, we only want to include only students whose names are six or more characters long. This requirement cannot be met with the pre-defined filters in Power Query. Therefore, we need to create a custom filter.

You can view this post with the tier: Academy Membership

Join academy now to read the post and get access to the full library of premium posts for academy members only.

Join Academy Already have an account? Sign In