Open In App

Power Query Editor in Power BI

Last Updated : 02 May, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Power Query Editor is a tool in Power BI Desktop used for data transformation and preparation. It allow to connect, shape and transform multiple data sources according to the user's needs. After making the desired changes the transformed data is then loaded to the Power BI desktop to fetch final outputs and reports. It can be in two modes as desktop or online.

When we upload data from various sources be it the internet, any Excel file or SQL server or any other source the uploaded data is not in the desired format. Data transformation helps clean and organize the data by removing unnecessary rows, splitting columns, and changing formats before loading it into Power BI for analysis.

Launching Power Query Editor

To open the Power Query Editor click Transform Data under the Home tab in Power BI Desktop. This will open the editor where you can load and transform your data.

lauch.png
Launching Power Query Editor

Now we will add data to query editor to perform desired operations.

Importing Data

In the Power Query Editor click New Source to add data from different sources like Excel, SQL, or the web. After importing you can perform necessary transformations on the data. The data referred to here for illustration purposes is an Excel file named My movie list.xlsx and its data is as follows:

list.png
My Movie List.xlsx

On loading this data on the query editor it appears as:

list-2.png
Excel sheet in the power query editor

Now since we have the Excel sheet and data imported on the power query editor as well we can perform transformations.

Common Data Transformations

1. Renaming Elements

The power query editor provides us with a variety of possible renaming. We can rename the data sources or tables, columns and queries. We will look into each of them one by one.

Rename Data Source 

It can be achieved by right-clicking on the source and opting for the rename option. Here, we have renamed the data source from sheet 1 to Movie Data. On transformation, we get :

rename-@.png
Renamed source to "Movie Data"

Rename Column

It's also done by right-clicking the column in which you wish to change the name and selecting the option of renaming and renaming as per the wish of the user. Here, we have renamed the column "TITLE" to "MOVIE NAME". On renaming the column it appears as :

rename-b.png
Renamed column to "MOVIE NAME"

Rename Query

Under the query settings pane an "Applied Steps" section under which all the changes we made are stored as queries. Using the query editor we can rename the queries also. Here, we have renamed the query "Renamed Columns" to "Columns Name Updation". On renaming it appears as :

rename-c.png
Renamed query to "Columns Name Updation"

2. Make First Row As the Header in Power BI 

This operation is used to set the first row as the column header. This option is available under the "TRANSFORM" of the ribbon. It has another option of "Use Headers as First Row" as well.

40.png
Set First Row as Headers

3. Change Data Types of a Column in Power BI

To change a column’s data type in Power BI, right-click the column, select Change Type, and choose the appropriate data type (e.g., "Whole Number" to "Decimal Number"). For example, we changed the "RANK" column from whole numbers (1, 2, 3) to decimal numbers (1.2, 2.3, 3.4). You can also change data types from the Home tab under "Data type"

20.png
Changed data type to "Decimal Number"

4. Format Operation in Power BI

The Format feature in the Transform tab helps format text in Power BI. You can change text to uppercase or lowercase, add prefixes or suffixes, and remove leading or trailing spaces using the Trim option. The Clean option removes non-printable characters. To use these simply click the relevant option. In this example we applied the UPPERCASE transformation but the other options work the same way.

30.png
Formatting the text to UPPERCASE

5. Removal Operation in Power BI

Remove Row Operation

The Reduce Rows feature in the Home tab allows you to remove rows in Power BI. You can remove top, bottom, or alternate rows, as well as duplicates, blank rows and errors. For example you can easily remove the bottom row and other removal operations work in the same way.

50.png
Removing the bottom row
reduce-rows.png
"Reduce Rows" Block

Please note that the "Reduce Rows" block in Power BI offers two options: "Remove Rows" and "Keep Rows". We have illustrated the "Remove Rows" operation above. On the same lines the "Keep Rows" operation is performed. The "Keep Rows" feature lets you select the rows you want to keep while "Remove Rows" deletes unwanted rows.

Remove Column Operation

The Remove Columns feature allows you to delete one or more columns. It's found under the "Home" tab in the Manage Columns section. You can click "Remove Columns" to delete the selected column or use "Remove Other Columns" to delete all columns except the one you selected. For example if you remove the "RATING" column it will no longer appear in your data.

remove-column.png
Removing Column Rating

Output:

output_remove_column.png
"RATING" column has been successfully removed.
manage-columns.png
"Manage Columns" block

The Manage Columns block has two features: Choose Columns and Remove Columns. Choose Columns lets you keep the columns you want while Remove Columns lets you delete the ones you don't need.

6. Merge Operation in Power BI

We can merge multiple columns. To select multiple columns hold down the Ctrl key, navigate to the columns you want to be selected using the left and right arrows, and then press the Space bar to actually select those columns. The "Add Column" bar supports the "Merge Columns" feature which is followed by a prompt of merge columns that asks for the name of the merged column and to set the separator. Here, we have merged the columns "GENRE" and "RATING". We have used a custom separator " ;) " and kept the name of the merged column simple as "Merged". The illustration along with the output is as follows :

60.png
Merging Columns GENRE and RATING

Output:

output-of-6.png
Merged Column

Replace Values Operation in Power BI

Replace values operation replaces some specific value to our desired value. It's present in the "Transform" bar as "Replace Values". Here, we have replaced "null" to "geeksforgeeks" for column "GENRE".

71.png
Replacing values of column "GENRE"
72.png
Replacing "null" to "geeksforgeeks"

Output:

73.png
Successfully Replaced


Split Column Operation in Power BI

It's present in the "Transform" bar on the ribbon. In the transform bar lies an operation as "split column". We can split either by using a delimiter, by providing no. of characters or positions, and so on. Here, we have split the column "Merged" using the customized delimiter " ;) " that splits the column into two columns "Merged.1" and "Merged.2". The illustration is as follows :

81.png
Splitting column "Merged"

Before 

before.png
Before Split Scenario

After

after.png
After Split Scenario

Particularly for PIVOT and UNPIVOT operations, we will refer to some other examples as the data we have been using so far will produce huge output and would not be so comprehensible and also can't be uploaded here.

Pivot Column Operation in Power BI

The pivot operation basically turns rows into columns. By default, the query editor does sum as aggregation which can also be set as don't aggregate or minimum or maximum or whatever as per the user's wish from available options. It is present in the "Transform" bar.

pivot.png
Pivot column "Field 2"

In the output we see 9.3 corresponding to 2 and not multiple values such as 1.1, 4.3, and 3.9. It's because we have set the aggregate value function as sum i.e. it will sum all the values of 1.1, 4.3, and 3.9 which is "9.3". Also, for 3 and 9 we have no repetitions so data corresponding to them is shown as "2.6" for each respectively.

Unpivot Column Operation in Power BI

Unpivot column operation as the name also suggests does the opposite of what pivot does. Unpivot basically unpacks similar values and gathers them under one label. When we did unpivot on the same data we took for the pivot operation it produces the output:

100.png
Unpivot operation implemented on Field 1 and Field 2 both

Output:

101.png
On unpivoting both the columns

Next Article
Article Tags :

Similar Reads