Skip to content
Home » Power BI Exercise » Power BI Exercise – Data Transformation in Power Query

Power BI Exercise – Data Transformation in Power Query

5/5 - (1 vote)

Enhance your Data Transformation skills in Power Query. Learn how to split dates into Year, Month, and Day columns, remove duplicate rows based on OrderID, and calculate a 10% tax on sales amounts using custom columns.

Tasks:

  1. Split the Order Date column into separate Year, Month, and Day columns.
  2. Remove duplicate rows based on OrderID.
  3. Add a new column that calculates a 10% tax on the Amount.

Solution:

Load the below dataset into Power BI-

Orders Dataset

OrderID Customer Name Product Order Date Amount
101 John Doe Laptop 15-Jan-24 1000
102 Jane Smith Smartphone 20-Feb-24 800
103 Alice Brown Tablet 05-Mar-24 600
104 Bob Johnson Printer 18-Mar-24 400
105 Charlie Green Headphones 10-Apr-24 200
106 Daisy White Laptop 22-Apr-24 1200
107 Ethan Black Smartphone 01-May-24 950
108 Fiona Gray Tablet 15-May-24 700
109 George Hill Printer 10-Jun-24 450
110 Hannah Adams Headphones 25-Jun-24 300

Split the Order Date column into separate Year, Month, and Day columns-

Step-1: Right-click on the Orders dataset and select Edit Query.

Edit query in Power BI
Edit query in Power BI

Step-2: The Power Query Editor window will open. Then, select the Order Date column and click on Split Column > By Delimiter.

Split columns in Power Query
Split columns in Power Query



Step-3: Select the options below. Here, we will split the column using the hyphen (-) as the delimiter.

Split by delimiter
Split by delimiter

Step-4: As shown in the screenshot below, the Order Date column has been split into three separate columns: Day, Month, and Year

Split date columns result
Split date columns result

Step-5: Now, double-click on the column name to rename it.

Rename the columns in Power Query
Rename the columns in Power Query

Remove duplicate rows based on OrderID-

Use the Remove Duplicates feature to eliminate duplicate rows by selecting the OrderID column.

Right-click on the OrderID column and select Remove Duplicates. This will remove the duplicate OrderID rows, if any, and a new transformation step will be added under Applied Steps.

Remove duplicate rows in Power Query
Remove duplicate rows in Power Query

Add a new column that calculates a 10% tax on the Amount-

Add a Custom Column with this formula. Refer to the screenshot below

[Tax amount] = [Amount] * 0.1
  • Click on the Add Column tab.
  • Next, click on Custom Column.
  • Provide the column name as Tax amount.
  • Select the Amount column, click on << Insert, and then add * 0.1 after [Amount].
  • Finally, click the OK button
Add custom column in Power BI
Add custom column in Power BI

See the result of the Tax Amount in the screenshot below.

Tax column
Tax column

Next, go to the Home tab, click on the Close & Apply dropdown, and select Close & Apply to save the transformation changes.

Close & Apply
Close & Apply

I hope you enjoyed this Power BI exercise.

Loading

Leave a Reply

Discover more from Learn BI

Subscribe now to keep reading and get access to the full archive.

Continue reading