Power BI Tutorial - Power BI Transformations
Posted by Superadmin on August 19 2020 17:33:55

Power BI Transformations

 

In real-time, we don’t get the data that we can directly use in the reports. I mean, we have to clean that data to meet our business standards. Within the Power BI desktop, we have a power query editor to perform all the operations that we needed. This section of the Power BI tutorial explains most of the data transformations that you need.

  1. Bins
  2. Change the Data type of a Column
  3. Combine Multiple Tables
  4. Clusters
  5. Enter data or Copy & Paste data from Clipboard
  6. Format Dates
  7. Groups
  8. Hierarchies
  9. Joins
  10. Pivot Table
  11. Query Groups
  12. Reorder or Remove Columns
  13. Rename Column Names
  14. Rename Table Names
  15. Split Columns
  16. UnPivot Table

Create Bins in Power BI

Power BI Bins or buckets are useful to create a Range of data, similar to SQL Buckets. Let me show you how to create bins in Power BI with an example

  

For this Power BI bins demonstration, we are going to use the SQL Data Source that we created in our previous article. So, Please refer Connect to the SQL Server article to understand the Data Source.

Create Bins in Power BI

To visually demonstrate this Power BI bins, we will create a Table. As you can see from the screenshot below, we created a simple Table by dragging the Product Key and Sales Amount column.

NOTE: I suggest you refer to Create a Table and Format Table article to understand the steps involved in creating and formatting a Power BI Table.

Create Bins in Power BI 1

Please select the filed that you want to use as a bin, and right-click on it opens the context menu. Select the New Group option from the menu.

  Create Bins in Power BI 2

Clicking the New Group option opens the following window.

If you selected the Bin Type as Size of Bins, then you have to specify the Bin size (static Number)

Create Bins in Power BI 3

Alternatively, if you selected the Bin Type as Number of Bins, then you have to specify the Bin count. Here, Bin size depends upon the Bin count.

Create Bins in Power BI 4

Let me select the Bin size as 20 and click OK. It means each bucket size is 20

Create Bins in Power BI 5

Now you can see the newly created bin under the Product table.

Create Bins in Power BI 6

Let me add that bin to this table. From the below screenshot, you can see that the product Key value is 220 for the keys between 220 to 240

Create Bins in Power BI 7

Edit Power BI Bins

Please select the bin that you want to edit, and right-click on it opens the context menu. Select the Edit Groups option from it

Create Bins in Power BI 8

Clicking the Edit Groups option opens the following window. Use this window to change as per your requirement.

Create Bins in Power BI 9

Delete Bins in Power BI

Please select the bin that you want to delete, and right-click on it opens the context menu. Select the Delete option form it

Create Bins in Power BI 10

Click the Delete button to confirm the delete operation. 

 

Create Bins in Power BI 11

Create Bins in Power BI Example 2

To demonstrate the Bins, we created a Column chart that shows Color wise sales. This time we create a bin on Sales Amount

Create Bins in Power BI 12

Right-click on the Sales Amount, and select the New Group option from the context menu. As you can see from the below screenshot, we defined the Power BI Bin size as the 357.2655

Create Bins in Power BI 13

Let me add this new Sales Amount bin to the Column chart legend section.

Create Bins in Power BI 14

Let me Edit the Power BI Bin, and change the Bin type to Number of Bins, and Bin count to 3

Create Bins in Power BI 15

Now you can see, each bar in the column chart divided by a bin of count 3.

Create Bins in Power BI 16

 

Change Data Types of a Column in Power BI

Generally, when you load a table from any data source, Power BI automatically detects the data type of a column. However, there may be some situations where Power BI might get them wrong.

 

For example, it may consider amounts, values, or even dates as the text. In these situations, you can use Power BI change data types of a column option. Let me show you how to Change Data Types of a Column in Power BI with an example.

How to Change Data Types of a Column in Power BI

To demonstrate this Change Data Types of a Column, we are going to use the excel table that we imported in Enter Data article.

To change data types of any column, please click the Edit Queries option under the Home tab.

Change Data Types of a Column in Power BI 1

Clicking Edit Queries option opens a new window called Power BI Power Query Editor.

 

From the screenshot below, you can see Yearly Income, Sales, and HireDate columns loaded as the text.

Change Data Types of a Column in Power BI 2

There are a couple of ways to change data types of columns

First Approach to Change Data Types of a Column

Please select the Column for which you want to change the data type. Next, click on the left corner of the column header (currently it represent ABC text)

Change Data Types of a Column in Power BI 3

Clicking in that position opens a drop-down list of supported data types. Please select the data type that suits your data. Here, we are selecting the Whole number.

Change Data Types of a Column in Power BI 4

Changing the data type of a column opens the following pop up window. Click on the Replace Current button.

Change Data Types of a Column in Power BI 5

Now you can see the Yearly Income header is displaying 123 (whole number) not ABC (text)

Change Data Types of a Column in Power BI 6

Second Approach to Change Data Types of a Column in Power BI

Please select the Column name that you want to alter the data type, and click on the Data Type button under the Home tab

Change Data Types of a Column in Power BI 7

It shows you the drop-down list of available data types. For the demo purpose, we are selecting a Fixed Decimal Number.

Change Data Types of a Column in Power BI 8

This time we will select the Add New Step. It means this change column type add as a new step under the Applied Steps.

Change Data Types of a Column in Power BI 9

As you can see from the screenshot below, it changed the data type of the Sales column and added a new step under the Applied Steps. 

 

Change Data Types of a Column in Power BI 10

Third Approach to Change Data Types of a Column in Power BI

Please select the column that you want to change the data type, and right-click on it will open the context menu. Select the Change Type and then the data type from the list. For now, we are selecting the Whole Number.

Change Data Types of a Column in Power BI 11

Don’t forget to hit the Close & Apply option under the Home tab to apply these changes.

 

 

 

 

Combine Multiple Tables in Power BI

Combine Multiple Tables in Power BI: In real-time, your data is in a normalized format, but in some situations, you might need the de-normalized data. In this situation, you can combine those tables using a query editor. Let me show you how to combine multiple tables in Power BI with an example.

 

How to Combine Multiple Tables in Power BI

From the screenshot below, you can see that there are three tables Product category, Product Subcategory, and Products table. We imported these tables in Connect to SQL article.

For the Combine Multiple Tables in Power BI demonstration purpose, we are going to combine these three tables. To do so, please click the Edit Queries option under the Power BI Home tab.  

 

Combine Multiple Tables in Power BI 1

Clicking Edit Queries option opens a new window called Power Query Editor.

From the screenshot below, you can see that the Product Subcategory table has a connection with both the Product and Product Category table.

  Combine Multiple Tables in Power BI 2

Before we start combining multiple tables in Power BI, let me duplicate this table by right-clicking the table and selecting the Duplicate option from the context menu.

Combine Multiple Tables in Power BI 3

We renamed it Product Information

Combine Multiple Tables in Power BI 4

Click on the table on any row show you the respective table information.

Combine Multiple Tables in Power BI 5

To combine the Dim Product table, Please click on the right corner of the Dim Product column header. It opens the following window. Use this window to select the required fields from the product table.

Combine Multiple Tables in Power BI 6

We selected the Product Key, Product Name, Color, and Standard Cost from the product table

Combine Multiple Tables in Power BI 7

Now you can see those columns inside the product information table.

Combine Multiple Tables in Power BI 8

To combine the Dim Product Category table, right corner of the Dim Product Category column header. Please select the required fields from the product category table.

We just need the English product Category Name from this table

Combine Multiple Tables in Power BI 9

Now you can see the English product category name inside the Product information table.

Combine Multiple Tables in Power BI 10

Let me rename and rearrange columns, and hit Close & Apply option under the Home tab. 

 

Combine Multiple Tables in Power BI 11

Let me create a table with this newly created table. As you can see from the screenshot below, we also formatted the Table as well.

NOTE: I suggest you refer to Create a Table, and Format a Table articles to understand the table creation and formatting options.

Combine Multiple Tables in Power BI 12

 

 

 

Power BI Clusters

In this section, we show you how to create Power BI clusters with an example. To explain this Clusters concept, we are going to use the Scatter Chart that we created earlier.

 

For this Power BI clusters demonstration, we are going to use the SQL Data Source that we created in Connect to SQL Server article and Scatter Chart.

Power BI Clusters 1

Create Power BI Clusters

Please click on the  (3 dots) on the top right corner of the chart to see the Clusters option. As you can see from the Power BI screenshot below, we selected the Automatically find Clusters option from the menu.  

 

Power BI Clusters 2

Clicking the Automatically find Clusters option opens the following Clusters window

For this Power BI cluster demo, we are leaving all the default values. So, let me click the OK button

  Power BI Clusters 3

An auto option has generated three clusters

Power BI Clusters 4

Edit Power BI Clusters

You can edit the cluster in two ways. Under the Visualization tab, click the down arrow beside the Cluster, and select the Edit Cluster option from the menu.

Power BI Clusters 5

Or, please select the Cluster that you want to edit, and right-click on it opens the context menu. Please select the Edit clusters option from it

Power BI Clusters 6

Clicking the Edit clusters option opens the following window. Use this window to change as per your requirement.

Power BI Clusters 7

Let me change the default three to six

Power BI Clusters 8

Now you can see, it has generated six different clusters

Power BI Clusters 9

Delete Power BI Clusters

Please select the Cluster that you want to delete. Next, right-click on it and select Delete option from the context menu.

Power BI Clusters 10

Confirm Delete

Power BI Clusters 11

Create Manual Power BI Clusters

It is the same as the first example, but this time we are changing the Number of Clusters value from Auto to 5.

Power BI Clusters 12

and you can see the 5 clusters 

 

Power BI Clusters 13

Let me use this cluster on another (different) report. For this, we created a Bar Chart using Postal Code Cluster (newly created) and Sales Amount

Power BI Clusters 14

Like normal columns, you can also Filter Clusters

Power BI Clusters 15

How to Enter Data into Power BI

Let me show you how to Enter Data into Power BI Desktop with an example. In real-time, you might face a situation like manually entering table data, or copying data from the text file to your power bi work environment. In these situations, you can use Power BI enter data option.

 

How to Enter Data into Power BI

To enter new data into the Power BI Desktop, please click Enter Data option under the Home tab.

How to Enter Data into Power BI 1

Clicking Enter Data option opens a new window called Create Table. Here, you can create new columns and add new rows.  

 

How to Enter Data into Power BI 2

By clicking the Column1 area, allow you to add a new name. Let me change the Column 1 header as the Name. Next, click on the * to add a new column.

How to Enter Data into Power BI 3

Now you can see the New column in Power BI.

  How to Enter Data into Power BI 4

For the demonstration purpose, let me add a few rows

How to Enter Data into Power BI 5

Use the Textbox beside the Name: filed to change the Table name. As you can see from the screenshot below, we changed the table name as Example 1.

Next, click on the Load button to load this table into Power Bi desktop. You can also click the Edit button to edit these fields.

How to Enter Data into Power BI 6

Please wait until the Load completed.

How to Enter Data into Power BI 7

Now you can see the New table

How to Enter Data into Power BI 8

Enter data from Excel file to Power BI Desktop

In this example, we explain the steps to paste the data from Excel file to Power BI desktop. First, let me open the Create Table window by clicking the Enter data button

How to Enter Data into Power BI 9

Let me copy the data present in the Excel file

How to Enter Data into Power BI 10

And paste it in the Create table window (Control + C and Control + V). Remember, Power BI automatically detects the column headers.

How to Enter Data into Power BI 11

Let me rename the table as ExcelEmployee and click the Load button

How to Enter Data into Power BI 12

Now you can see the table 

 

How to Enter Data into Power BI 13

Enter data from SQL table to Power BI Desktop

First, let me copy the data present in the SQL table

How to Enter Data into Power BI 14

and paste it in the create table window

How to Enter Data into Power BI 15

Please rename the table name as per your requirement, and hit the Load button

How to Enter Data into Power BI 16

Now you can see the table

How to Enter Data into Power BI 17

Enter data from Text file to Power BI Desktop

First, let me open the text file. As you can see, the file not formatted properly. Let me copy the content in this text file.

How to Enter Data into Power BI 18

Next, we pasted it in the create table window. You can see from the screenshot below, all the information stored in one column.

We can edit them by hitting the Edit button, but we will write a separate article to explain those techniques. Therefore, for now, we renamed the table name and loaded the table into the desktop.

How to Enter Data into Power BI 19

How to Format Dates in Power BI

How to Format Dates in Power BI with an example?. Using these formatting Date options, you can extract Year, Month, Day, Day Number, Day name, Month Start and End, etc.

 

How to Format Dates in Power BI

To demonstrate these Power BI date formats, we are going to use the SQL table that we imported in Enter Data article.

To format dates in any table, please click the Edit Queries option under the Home tab.  

 

How to Format Dates in Power BI 1

Clicking the Edit Queries option opens a new window called Power Query Editor.

From the screenshot below, you can see the HireDate column. To demonstrate the Power BI date formatting options, we are going to use this column.

  How to Format Dates in Power BI 2

There are a couple of ways to format dates in power bi

The first approach to Format Dates in Power BI

Please select the Date Column, and right-click on it open the context menu. Select the Transform option and select the formatting option. For now, we are selecting the Year. It means this property extract and displays the Years from Hire date.

How to Format Dates in Power BI 3

From the screenshot below, you can see the date and Time in the Hire date column replaced by the Extracted Year.

How to Format Dates in Power BI 4

The second approach to Format Dates in Power BI

First, go to Transform Tab. Under this tab, you can see the Date and Time options. You can use these drop-down lists to format the dates.

How to Format Dates in Power BI 5

Clicking the down arrow beside the Date show you the drop-down list of available date formats. For the demo purpose, we are selecting Days in Month.

How to Format Dates in Power BI 6

From the below screenshot, you can see the date and Time in the Hire date column replaced by the total number of days in a month.

How to Format Dates in Power BI 7

The third approach to Format Dates in Power BI

The above-specified approaches are replacing the existing column with the formatted date. But, this approach adds an extra column for the formatted date.

First, go to Add Column Tab. Under this tab, you can see the Date, Time, and Duration options. You can use these drop-down lists to format the date and Time.

How to Format Dates in Power BI 8

Let me select Date Only option in Power BI.

How to Format Dates in Power BI 9

Now you can see the new column (extra column) displaying the date from the Hire date 

 

How to Format Dates in Power BI 10

Let me Select Time Only

How to Format Dates in Power BI 11

Now you can see the new column displaying the Time from Hire date

How to Format Dates in Power BI 12

Let me select the name of the day

How to Format Dates in Power BI 13

Now you can see the extra column displaying the day name. Next, hit the Close & Apply option under the Home tab to apply these changes.

How to Format Dates in Power BI 14

Please wait until the changed are applied

How to Format Dates in Power BI 15

Now you can see the Date, Day Name, and Time columns under the SQL Employee table.

How to Format Dates in Power BI 16

Create Groups in Power BI

Power BI Grouping is the process of combining or merging two or more values for further analysis. For example, When we are seeing products by category report, we may find very few records (unnoticeable products). Sometimes, it may be annoying to see all those underperforming products. In this situation, you can create a Power BI group by combining those records, and display it as one product.

  

In this article, we show you how to create groups in Power BI reports with an example. For this Power BI groups demonstration, we are going to use the SQL Data Source that we created in our previous article.

Please refer Connect to SQL Server article to understand the Power BI Data Source.  

 

Create Groups in Power BI

To visually demonstrate this Power BI grouping technique, we will create a Pie chart. As you can see from the below screenshot, we created a Pie chart by dragging the Sales Amount column to Values field, and Color to Legend region.

NOTE: I suggest you to refer Create a Pie Chart, and Format Pie Chart article to understand the steps involved in creating, and formatting a pie chart.

  Create Groups in Power BI 1

If you observe the below screenshot, Data that we highlighted such as Multi, NA, and Blue color products are not performing well. So, let us group them

Create Groups in Power BI 2

To perform grouping in Power BI, Please select the fields that you want to group, and right-click on it will open the context menu. Please select Group option from the menu.

Create Groups in Power BI 3

Once you Click on the Group option, Power BI will automatically group those items as shown below. That’s it, we did the grouping.

If you observe closely, Legend section is replaced by Color group, and the color is placed in the details section.

TIP: By default, Power BI Group option will group the selected items as one group and remaining options as another group.

Create Groups in Power BI 4

Let me remove the Color field from the Details section. Now you can see only two partitions in the Pie chart: one contains Blue, White and NA colours, and the second partition contains remaining colours.

Create Groups in Power BI 5

Edit Power BI Group

Please select the group that you want to edit, and right-click on it will open the context menu. Select the Edit Groups option form it

Create Groups in Power BI 6

Clicking the Edit Groups option will open the following window.

Create Groups in Power BI 7

Let me uncheck the Include Other group. This will remove others group

Create Groups in Power BI 8

Now you can see the pie chart that is displaying all the colours, and one group that contains Blue, Multi and NA colours. 

 

Create Groups in Power BI 9

Remove Power BI Group Members

To remove Power Bi group members, Please select the group member that you want to remove, and click ungroup button. For the demo purpose, we are removing the Blue colour.

Create Groups in Power BI 10

Now you can see that the Blue colour is removed, and added under the ungrouped values

Create Groups in Power BI 11

And our pie chart is displaying all the colours, and one group that contains Multi and NA colours.

Create Groups in Power BI 12

Rename a Group in Power BI

Double-click on the group that you want to rename, and provide a valid name. Let me rename it as White & Multi & NA

Create Groups in Power BI 13

From the below screenshot, you can see that the group name is renamed.

Add a Member to Groups in Power BI

Please select the group member that you want to add, and select the group as well. Next, click on the Group button.

For the demo purpose, we are adding White colour to an existing group.

Create Groups in Power BI 14

Now you can see the White colour under the group

Create Groups in Power BI 15

Create a New Group in Power BI

Please select the field for which you want to create a group, and click the group button. For the demo purpose, we are selecting the Yellow colour.

Create Groups in Power BI 16

Now you can see the new group.

Create Groups in Power BI 17

Let me add a few more fields to it

Create Groups in Power BI 18

Now you can see, our pie chart has four colours, and they are: Black, Red, and two groups

Create Groups in Power BI 19

Once you created a Group in Power BI, it will act like any other column or fields. So, you can use it in N number of charts.

To demonstrate the same, we created a Column chart that shows the Country wise sales.

Create Groups in Power BI 20

Next, we added the Color group in the legend section.

Create Groups in Power BI 21

The second approach to create Groups in Power BI

Please select the filed that you want to use as a group, and right-click on it will open the context menu. Select the New Group option from the context menu.

Create Groups in Power BI 22

This will open the following window

Create Groups in Power BI 23

Sometimes, Power Bi will open the same window with the different option like we shown in the below screenshot. But, don’t worry, you can change the Group type from Bin to List

Create Groups in Power BI 24

Once you changed that property, you are good to go

Create Groups in Power BI 25

 

 

Create Hierarchy in Power BI

Power BI Hierarchies provide you with the drill down action to the BI report. Let me show you how to Create hierarchy in Power BI reports with an example.

  

How to Create Hierarchy in Power BI

To demonstrate the creation of hierarchies in Power BI, we are going to use the table that we created in the Combine Multiple Tables article.

Create Hierarchy in Power BI 1

There are a couple of ways to create a hierarchy

The first approach to Create Hierarchy in Power BI

To create a new hierarchy in Power BI, Drag and drop one field on to the other. It automatically creates a Hierarchy for you. To demonstrate the same in Power BI, we are dragging the product subcategory onto the product category field.

Create Hierarchy in Power BI 2

Now you can see the newly created hierarchy.

  Create Hierarchy in Power BI 3

The first approach to add fields to a Power BI hierarchy

Drag and drop the required field to the newly created hierarchy. Let me drag the color field.

Create Hierarchy in Power BI 4

Now you can see the Color field inside the Hierarchy.

Create Hierarchy in Power BI 5

The second approach to add fields to a Power BI hierarchy

Please select the field that you want to add (let me select product), and right-click on it will open the context menu. Select the Add to Hierarchy, and then select the Hierarchy name (Product Category Hierarchy)

Create Hierarchy in Power BI 6

Now you can see the Product under the hierarchy.

Create Hierarchy in Power BI 7

Change Hierarchy Levels in Power BI

Please be careful while configuring the hierarchy levels. For instance, if you have the State column above the Country, then Level 1 is State, level 2 is the Country.

Please select the field that you want to change the position or level. Next, right-click on it and select the Move Up option (or move down) from the context menu. Alternatively, you drag and drop the field at the required position.

Create Hierarchy in Power BI 8

Now you  can see the product at the third position

Create Hierarchy in Power BI 9

Rename Hierarchy in Power BI

Please select the Hierarchy that you created, and right-click on it will open the context menu. Select the Rename option from the context menu. Alternatively, you can double-click on the hierarchy name

Create Hierarchy in Power BI 10

Let me rename it as the product hierarchy

Create Hierarchy in Power BI 11

Now you can see the new name 

 

Create Hierarchy in Power BI 12

Delete Hierarchy in Power BI

Select the Hierarchy that you delete, and right-click on it open the context menu. Please select the Delete option from the context menu.

Create Hierarchy in Power BI 13

Click on the Delete button to confirm the delete operation.

Create Hierarchy in Power BI 14

The second approach to create Hierarchy in Power BI

Please select the filed that you want to use in Hierarchy, and right-click on it will open the context menu. Select the New Hierarchy option from the context menu.

Create Hierarchy in Power BI 15

It creates a new hierarchy for you.

Create Hierarchy in Power BI 16

Let me add a few more fields

Create Hierarchy in Power BI 17

Delete Fields from Hierarchy

Please select the field that you want to remove or delete from the hierarchy. Next, right-click on it and Delete option from a context menu.

Create Hierarchy in Power BI 18

Click the delete button to delete the Color field from the hierarchy.

Create Hierarchy in Power BI 19

You can see the same in the below screenshot

Create Hierarchy in Power BI 21

Again, we added the Color field and renamed the hierarchy as the Product Information.

Create Hierarchy in Power BI 21

 

 

 

 

 

 

 

Joins in Power BI

Power BI supports all major joins that are available in SQL. Let me show you how to use joins in Power BI to join multiple tables with an example.

  

The following join types are the Standard join types in Power BI and SQL

  1. Inner Join: Returns the rows present in both Left and right table only if there is a match. Otherwise, it returns zero records.
  2. Full Outer Join: It returns all the rows present in both the Left and right table.
  3. Left Outer Join: It returns all the rows present in the Left table and matching rows from the right table (if any).
  4. Right Outer Join: Returns matching rows from the left table (if any), and all the rows present in the SQL Right table.

How to Perform Joins in Power BI

To demonstrate the Power BI join types, we are going to use the tables that we imported in the Load Data from Multiple Data Sources article.

To show the join operations on existing tables, please click the Edit Queries option under the Home tab.

Joins in Power BI 1

The below Power BI screenshot show you the data present in the Employees table

  Joins in Power BI 2

The following screenshot shows you the data present in the Department Table.

To perform Power BI Join operations on any table, we have to use the Merge Queries button present in the Home tab

Joins in Power BI 3

This drop-down list has two options:

Joins in Power BI 4

Let  me select the Employees table, and select Merge Queries as a New option because we don’t want to disturb the original table

Joins in Power BI 5

The following window will open. Use this window to select the Second Table, Join Type, and standard column filed in both the tables.

Joins in Power BI 6

We are selecting the Department table as the second table.

Joins in Power BI 7

Now you can see the list of supporting join types.

Left Outer Join in Power BI

For now, we are selecting the Left Outer Join

Joins in Power BI 8

Next, we selected the DeptID from Employees and Department table as the common fields

Joins in Power BI 9

Now you can see the new table called Merge1 with all the fields from the Employees table along with one extra filed of values table 

 

Joins in Power BI 10

Click on the table on any row show you the respective table information

Joins in Power BI 11

Please click on the right corner of the Department column header. This will open the following window. Use this window to select the required fields from the department table.

Joins in Power BI 12

Let me select the Department name from the department table, and click OK

Joins in Power BI 13

Now you can see the Department name merge with the Employee table.

Joins in Power BI 14

Right Outer Join in Power BI

Let me select the Employees table as the first table, Department table as the second table. And the Dept Id is the common filed, and right outer join as the join type.

Joins in Power BI 15

Now you can see the new table result of the Power BI right outer join

Joins in Power BI 16

Full Outer Join in Power BI

Let me select the Employees table as the first table, Department table as the second table. Here, we select Dept Id is the common filed, and full outer join as the join type.

Joins in Power BI 17

Now you can see the result of Power BI Full outer join in a new table

Joins in Power BI 18

Inner Join in Power BI

Let me select the Employees and Department tables, Dept Id as the common field, an inner join as the join type

Joins in Power BI 19

Now you can see the result of Power BI Inner join in a new table

Joins in Power BI 20

Power BI Pivot Table

Power BI pivot table option converts selected rows into columns. Let me show you how to create a pivot table or how to convert the unpivoted table into a pivot table in Power BI with an example.

  

How to create a Power BI Pivot Table

To create a Power BI pivot table or to convert unpivot to a pivot table, please click the Edit Queries option under the Home tab.

Power BI Pivot Table 1

Clicking Edit Queries option opens a new window called Power BI Power Query Editor.  

 

In this example, we are going to pivot the calendar year column based on the order quantity.

Power BI Pivot Table 2

To convert the unpivot table into a pivot table, go to Transform Tab. Under this tab, you can find the pivot Column button as shown below.

  Power BI Pivot Table 3

Clicking the pivot Column button opens the following window.

Power BI Pivot Table 4

Let me select the Order Quantity as the values column

Power BI Pivot Table 5

Next, we selected the Sum as the aggregate function value

Power BI Pivot Table 6

Now you can see the pivot table

Power BI Pivot Table 7

What if your table had more than one static column (a column that won’t change in the pivot process)? For this, we added one more column called Product Id to this table.

Power BI Pivot Table 8

Let me select the Order Quantity column as the values column, and Sum as the aggregate function

Power BI Pivot Table 9

Now you can see the Pivot table in Power BI. Remember, having more than one unchanged static column will not make any difference in creating a pivot table.

Power BI Pivot Table 10

Next, hit the Close & Apply option under the Home tab to apply these changes.

Power BI Pivot Table 11

From the screenshot below, you can see the pivot columns.

Power BI Pivot Table 12

Create Query Groups in Power BI

This article shows you the steps required to Create Query Groups in Power BI with an example. In general, the tables that we load from the source arranged in alphabetical order. However, in real-time, we might have to group those tables based on the content.

 

For example, arrange Dimension tables in one group and fact tables as another.

How to Create Query Groups in Power BI

To create the Power BI query group on existing tables, please click the Edit Queries option under the Home tab.  

 

Create Query Groups in Power BI 1

Clicking Edit Queries option opens a new window called Power Query Editor. Under the Power BI Queries section, you can see the list of available tables.

Create Query Groups in Power BI 2

There are a couple of ways to create a new query group

 

The first approach to Create Power BI Query Group

To create a new query group, right-click on the empty space under the queries section and select the New Group option from the context menu.

Create Query Groups in Power BI 3

Selecting the New Group option will open the following window. Please specify the Group Name and the description. For now, we are assigning the Dimensions as the Group name.

Create Query Groups in Power BI 4

You can see the New folder (Query Group)

Create Query Groups in Power BI 5

The first approach to add Tables to Query Groups in Power BI

Right-click on the table that you want to add opens the context menu. Please select the Move to Group option, and then select Group Name, i.e., Dimensions.

Create Query Groups in Power BI 6

Now you can see the DimCustomer table under the Dimensions group

Create Query Groups in Power BI 7

The second approach to add Tables to Query Groups in Power BI

Drag the required table, and Drop under the Query group automatically add that table to the query group. For the demonstration purpose, we are dragging the Dim Employee table to the Dimension group.

Create Query Groups in Power BI 8

Similarly, we added the remaining dimension tables to the Dimension query group.

Create Query Groups in Power BI 9

The second approach to create Power BI Query Groups

To create a new query group, right-click on any table will open the context menu. Please select the Move to Group option, and then select the New Group option.

Create Query Groups in Power BI 10

Selecting the New Group.. option will open the following window. For now, we are assigning the Group name as measures.

Create Query Groups in Power BI 11

Rearranging tables in a Power BI Query Groups

By simply moving the table up and down will change the table position. 

 

Create Query Groups in Power BI 12

Alternatively, right-click on the table that you want to move will open the context menu. Please select the Move Down or Move Up option. For the demonstration purpose, we moved Dim Employee table to down.

Create Query Groups in Power BI 13

Now you can see the Dim Employee table in the third position.

Create Query Groups in Power BI 14

Delete Query Groups in Power BI

To delete the existing query group, right-click on the group name will open the context menu. Please select the Delete Group option.

Create Query Groups in Power BI 17

Selecting the Delete Group option opens the following message box. For now, we are clicking the Cancel button

Create Query Groups in Power BI 16

How to Ungroup existing Query Groups in Power BI

To ungroup or remove the existing group, right-click on the group name and select Ungroup option from the context menu.

Create Query Groups in Power BI 18

Now you can see that the Dimensions group removed.

Create Query Groups in Power BI 19

Nested Query Groups in Power BI

To add one group inside another group, right-click on the group name opens the context menu. Please select the Move to Group option and then select the Master Group name, i.e., Dimensions.

Create Query Groups in Power BI 20

Now you can see that the Measures Group Nested inside the Dimensions group.

Create Query Groups in Power BI 21

You can undo this by right-clicking the group name and selecting the Move to Top Level option from the context menu

Create Query Groups in Power BI 22

Whatever the changes you made (query groups) won’t affect until you hit Apply. Let me hit the Close & Apply option under the Home tab.

Create Query Groups in Power BI 23

Remove or Reorder Columns in Power BI

Generally, the data that we get from the source might have few columns that may not require for the analysis purpose. Let me show you the steps required to Remove or Reorder Columns in Power BI with an example.

  

How to Remove or Reorder Columns in Power BI

To reorder columns, or remove unwanted columns from the existing Power BI tables, please click Edit Queries option under the Home tab.

Remove or Reorder Columns in Power BI 1

Clicking the Edit Queries option opens a new window called Power Query Editor.  

 

From the below Power BI screenshot, you can see there are State codes, country codes, which are not required for the analysis purpose. So, let me remove those columns from this Power BI Geography table

Remove or Reorder Columns in Power BI 2

Remove Columns in Power BI

To remove Power BI columns, please select the Column that you want to remove and right-click on it open the context menu. Select the Remove option from the context menu

  Remove or Reorder Columns in Power BI 3

Now, you can see that the State-Province Code column removed from the table. And you can see the same under the Applied Steps section.

Remove or Reorder Columns in Power BI 4

Use Remove Other Columns option to remove all the columns from the table except the selected columns.

For the demonstration purpose, I am selecting City and selected the Remove Other Columns option from the context menu.

Remove or Reorder Columns in Power BI 5

As you can see, all the other columns except City removed from the Geography table.

Remove or Reorder Columns in Power BI 6

Alternatively, you can click on the Remove Columns button under the Home Tab

Remove or Reorder Columns in Power BI 7

Similarly, we removed the remaining unwanted columns.

Remove or Reorder Columns in Power BI 8

Reorder Columns in Power BI

Drag the required column and Drop at the position you want to place. For the Power BI reorder columns demonstration purpose, we are dragging Country Column to the second position (after geography Key).

Remove or Reorder Columns in Power BI 9

Now you can see the Country names in the second position

Remove or Reorder Columns in Power BI 10

Alternatively, right-click on the column name that you want to move will open the context menu. Please select the Move and then select Right, Left, To End, or To Beginning option

Remove or Reorder Columns in Power BI 11

Now you can see the State in the third position. Next, hit the Close & Apply option under the Home tab to apply these changes. 

 

Remove or Reorder Columns in Power BI 12

Please wait until the changed are applied

Remove or Reorder Columns in Power BI 13

How to Rename Column Names in Power BI

Let us see how to Rename Column Names in Power BI Desktop with an example. Generally, when you load the data from a data source, you get the column names that are available in a data source. While you are designing the report, you might need more meaningful names. In these situations, you can use the Power BI rename column names option.

  

How to Rename Column Names in Power BI

To demonstrate this Rename Column Names option, we are going to use the Text Employee table that we imported in Enter Data, and altered in split column article.

To rename the column names in an existing table, please click the Edit Queries option under the Home tab.  

 

How to Rename Column Names in Power BI 1

Clicking Edit Queries option opens a new window called Power BI Power Query Editor. From the screenshot below, you can see that the columns in this table have a common name.

How to Rename Column Names in Power BI 2

There are a couple of ways to rename column names in Power BI table report

 

To rename the columns in a table, right-click on the column that you want to rename will open the context menu. Please select the Rename option.

How to Rename Column Names in Power BI 15

It allows you to rename the column. Let me rename it as EmpID.

How to Rename Column Names in Power BI 4

Now you can see the column with EmpID name

How to Rename Column Names in Power BI 5

Alternatively, you can double-click on the column header.

How to Rename Column Names in Power BI 6

As you can see, we renamed it as the First Name

How to Rename Column Names in Power BI 7

Similarly, we renamed the remaining columns

How to Rename Column Names in Power BI 8

Whatever the changes you made won’t affect until you hit Apply. Let me hit the Close & Apply option under the Home tab.

How to Rename Column Names in Power BI 9

Please wait until the changed are applied

How to Rename Column Names in Power BI 10

Now you can see the more meaningful names

How to Rename Column Names in Power BI 11

How to Rename Table Names in Power BI

Let me show you how to Rename Table Names in Power BI with an example. In general, when you load the data from a data source, you get the table names directly from the data source. While you are working with Transformations, you might need more meaningful names. In these situations, you can use the Power BI rename table names option.

  

How to Rename Table Names in Power BI

To demonstrate this Power BI Rename Table Names option, we are going to use the tables that we imported in Connect to SQL article.

To rename the table names, please click the Edit Queries option under the Home tab.  

 

How to Rename Table Names in Power BI 1

Clicking Edit Queries option will open a new window called Power BI Power Query Editor.

From the screenshot below, you can see, when you select the table. You can see a table name under the properties section. You can use this section to rename the table.

  How to Rename Table Names in Power BI 2

Using the Properties window, we renamed the DimReseller table name as Reseller

How to Rename Table Names in Power BI 3

Now you can see the same

How to Rename Table Names in Power BI 4

Alternatively, you can right-click on the table name and select the Rename option from the context menu.

How to Rename Table Names in Power BI 5

Let me rename this as a Customer

How to Rename Table Names in Power BI 6

Now you can see that the table name has changed

How to Rename Table Names in Power BI 7

Similarly, we renamed the remaining tables. Next, hit the Close & Apply option under the Home tab to apply these changes.

How to Rename Table Names in Power BI 8

Please wait until the changed are applied

How to Rename Table Names in Power BI 10

Now you can see the more meaningful table names.

How to Rename Table Names in Power BI 10

How to Split Columns in Power BI

In real-time, you might get the data that has merged columns (one column with too much information). In that situation, you can use Power BI Split Columns option to split that column into multiple columns. This article shows you how to Split Columns in Power BI with example.

  

How to Split Columns in Power BI

To demonstrate this Power BI split columns option, we are going to use the Text Employee table that we imported in Enter Data article.

To split columns in an existing table, please click the Edit Queries option under the Home tab.  

 

How to Split Columns in Power BI 1

Clicking Edit Queries option opens a new window called Power Query Editor. From the screenshot below, you can see that the Power BI table has only one column.

How to Split Columns in Power BI 2

Before we start splitting the columns in Power BI, let me duplicate this column. To do so, right-click on the column name and select Duplicate Column option from the context menu.

  How to Split Columns in Power BI 3

Now you can see the Duplicate column

How to Split Columns in Power BI 4

To split the columns in a Power BI table, right-click on the column that you want to split open the context menu. Please select the Split Columns and then select By Delimiter option.

How to Split Columns in Power BI 5

Selecting the By Delimiter option opens the following window.

How to Split Columns in Power BI 6

We are selecting Comma as the delimiter. Remember, under the Advanced section, you can specify the Number of Columns or Rows.

How to Split Columns in Power BI 7

Let me select the Left Most delimiter option, and click OK

How to Split Columns in Power BI 8

Now you can see that the Employee ID’s are separated from the original column and placed in the new column.

How to Split Columns in Power BI 9

This time we select the Split at each occurrence of the delimiter option.

How to Split Columns in Power BI 10

Now you can see, text at each occurrence of the comma is separated from the original column and placed in a new column.

How to Split Columns in Power BI 11

Let me try another delimiter. For the Power BI Split Columns demonstration, we are selecting the following column and split that column using the Space delimiter.

How to Split Columns in Power BI 12

Now you can see the different columns that stored the split text at each occurrence of space. 

 

How to Split Columns in Power BI 13

Power BI Split Columns by Number of Characters

Right-click on the column that you want to split will open the context menu. Please select the Split Columns and then select the By Number of Characters option.

How to Split Columns in Power BI 14

Selecting the By Number of Characters option opens the Split Column by Number of Characters window.

How to Split Columns in Power BI 15

Now you can see the split columns in Power BI query editor

How to Split Columns in Power BI 16

Whatever the changes you made (Split Columns in Power BI) won’t affect until you hit Apply. Let me hit the Close & Apply option under the Home tab.

How to Split Columns in Power BI 17

Now you can see 11 columns inside the Text Employees table.

How to Split Columns in Power BI 18

Unpivot Table in Power BI

Power BI Unpivot table option converts selected columns into rows. Let us see how to create an Unpivot table or how to convert the pivot table into the unpivot table in Power BI with an example.

  

How to create unpivot Table in Power BI

To create or convert pivot to unpivot table, please click the Edit Queries option under the Home tab.

Unpivot Table in Power BI 1

Clicking the Edit Queries option opens a new window called Power BI Power Query Editor.  

 

In this Unpivot Table example, we are going to unpivot the columns 2005, 2006, 2006, and 2007.

Unpivot Table in Power BI 2

There are a couple of ways to unpivot table

 

The First approach to unpivot table in Power BI

Please select the columns that you don’t want to unpivot, or you want to keep them unchanged will open the context menu. Select the Unpivot Other Columns option. This unpivots all the columns except the selected ones.

Unpivot Table in Power BI 3

Now you can see the unpivoted table

Unpivot Table in Power BI 4

The second approach to unpivot table in Power BI

Please select the columns that you want to unpivot will open the context menu. Select Unpivot Only Selected Columns option. This unpivots all the selected columns.

Unpivot Table in Power BI 5

Now you can see the unpivoted table

Unpivot Table in Power BI 6

The third approach to unpivot table in Power BI

In order to convert the pivot table into the unpivot table, go to Transform Tab. Under this tab, you can find the Unpivot Column button as shown below.

Unpivot Table in Power BI 7

Use the drop-down list to unpivot the table. For the Unpivot Table demonstration purpose, we selected the Product ID, and Name columns, and then selected the Unpivot Other columns option.

Unpivot Table in Power BI 8

Now you can see the unpivoted table.

Unpivot Table in Power BI 9

We renamed the columns to more meaningful ones. Next, hit the Close & Apply option under the Home tab to apply these changes.

Unpivot Table in Power BI 10

From the screenshot below, you can see the unpivot columns on the right side.

Unpivot Table in Power BI 11