“Power Query Deep Dive: Combining, Grouping & Advanced Transformations”

Power Query is not just about basic cleaning—it is a powerhouse for transforming, combining, and preparing data for advanced reporting in Power BI. In this post, we will dive into some powerful features like merging, appending, grouping, column transformations, and more.
Merging & Appending Queries
Merging allows you to join two tables based on a common column (like Region or Product ID), while appending lets you stack data from multiple sources vertically.
Load two Excel tables (e.g., Sales Data and Region Info) into Power BI.
Go to Power Query Editor via Home > Transform Data.
To merge: Select Merge Queries, choose key columns (e.g., Region), pick a join type (e.g., Left Join), and confirm.
To append: Use Append Queries to stack rows from different datasets.
Click Close & Apply to finalize your changes.
Creating Parameters
Parameters allow you to make transformations dynamic—perfect for filtering data or setting file paths.
Load Excel table (e.g., Sales Data) into Power BI.
In Power Query Editor, go to Manage Parameters > New Parameter.
Give it a name (e.g., MinQuantity) and set its type and default value.
Field | Value |
Name | MinQuantity |
Description | Minimum quantity for filtering sales |
Type | Decimal Number or Whole Number |
Suggested Values | List of Values (e.g., 1, 5, 10, 25) or Any Value |
Default Value | 5 |
Current Value | 5 |
Use it in filters or conditional logic to make your query interactive.
Select your main table (e.g., Sheet1).
Click on the Quantity
Go to Home > Keep Rows > Keep Rows Where.
In the filter dialog, set:
Column Name: Quantity
Operator: is greater than or equal to
Value: Select your newly created parameter MinQuantity
Click Close & Apply when done.
Grouping and Aggregation
Use this feature to summarize data—like total sales per region or number of orders per product.
In Power BI, go to Home > Transform data.
Select a column like Region or Product.
Click Transform > Group By.
Choose the grouping column and set the operation
Group by: Product
New column name: Total Quantity
Operation: Sum
Column: Quantity
Click OK to create a summarized table.
You can also add another aggregation like "Average", "Count", or "Max/Min" by clicking "Add Aggregation".
Column Transformations (Replace, Split, Format)
These tools help standardize and clean your columns.
Replace Values:
Use Replace Values to fix spelling issues or standardize text.
Suppose in Product column, some rows say laptop and others say Laptop.
Select the Product column.
Go to Transform > Replace Values.
In the box:
Value To Find: laptop
Replace With: Laptop
Click OK.
Split Column:
Use Split Column to divide content by delimiter (e.g., space or comma).
Use this when you want to divide data in a column—for example, Customer Name → First Name & Last Name.
Select the Customer Name column.
Click Transform > Split Column > By Delimiter.
Choose Space as delimiter (to separate first and last names).
Click OK.
Now you will have two new columns: Customer Name.1 and Customer Name.2.
Format:
Use Format tools to trim spaces, change case, or clean formatting.
Use formatting tools to standardize text and remove unwanted characters.
Select the Customer Name column.
Go to Transform > Format:
Trim – removes extra spaces.
Clean – removes non-printable characters.
Uppercase / Lowercase / Capitalize Each Word – change case.
Example: " ravi " → Ravi
Error Handling
Sometimes data is not perfect. Power Query lets you handle errors gracefully.
When a column shows errors, click the error icon to investigate.
Use Remove Errors or Replace Errors from the Home tab.
For advanced logic, use try...otherwise in a custom column.
Simulate an Error (for practice)
Load the Excel File into Power BI
Open Power BI Desktop.
Click Home > Get Data > Excel.
Select the file Sample_Error_Data.xlsx.
Choose the sheet (e.g., Sheet1) and click Load.
Once loaded, go to Home > Transform Data to open Power Query Editor.
Detect Errors in Columns
Column: Order Date
The row with value invalid-date will trigger an error if you change the data type to Date.
Select the column → Click Transform > Data Type > Date.
Power Query will show an error icon in that row.
Column: Quantity
The value "two" is text. If you convert to a Whole Number, it will show an error.
Select the column → Change data type to Whole Number → Error appears.
Column: Unit Price
- Value "error" will break when changed to Decimal Number.
Handle Errors
Option A: Remove Errors
Click the column with errors (e.g., Quantity).
Go to Home > Remove Rows > Remove Errors.
This deletes only the rows that contain errors in that column.
Option B: Replace Errors
Click the column with errors (e.g., Unit Price).
Go to Transform > Replace Errors.
Enter a default value like 0 or 1000.
Option C: Use try...otherwise
This method handles errors during calculations.
Go to Add Column > Custom Column.
Name the column: Sales
Use this formula:
powerquery
CopyEdit
try [Quantity] * [Unit Price] otherwise 0
This calculates Quantity × Unit Price, and if either value causes an error, it replaces the result with 0.
Check for Nulls
Columns like Customer Name or Region may contain blank/null values.
Use Transform > Replace Values to replace null with "Unknown".
Finalize & Load
Once all transformations are done, click Home > Close & Apply.
Now your cleaned and error-handled data is ready in Power BI!
you need to replace the invalid date.
Applied Steps Pane
This panel tracks every transformation applied to your data.
Review steps in the Applied Steps pane on the right.
Click the ⚙️ gear icon to edit a step.
Delete or reorder steps to clean up or optimize transformations.
Load Your Excel File
Open Power BI Desktop.
Click Home > Get Data > Excel.
Select your previous file (e.g., Sample_Sales_Data.xlsx) and load the sheet.
Click Transform Data to open Power Query Editor.
Perform Transformations
Apply the following changes (just for practice):
Change Data Type:
Set Order Date to Date type.
Set Quantity and Unit Price to Whole Number or Decimal Number.
Add Custom Column:
Go to Add Column > Custom Column.
Name it Total Sales
Formula: [Quantity] * [Unit Price]
- Filter Rows:
Click the dropdown on Region.
Uncheck one of the regions to filter it out (e.g., remove South).
Observe the Applied Steps Pane
On the right side, you'll see each action recorded as:
Source – Imported Excel file
Navigation – Selected the correct sheet
Changed Type – Applied when data types are modified
Added Custom – For the Total Sales column
Filtered Rows – When you filtered out a region
Use the Gear Icon (⚙️)
For editable steps (like filters or grouping):
- Click the ⚙️ gear icon to modify the filter or transformation without undoing it manually.
Clean Up or Reorder
Right-click any step:
Select Delete to remove a mistake.
Use Move Up/Down to reorder steps (⚠️ only if later steps don’t depend on earlier ones).
Example:
If you accidentally filter before calculating Total Sales, it may skip data.
You can move the filter step down to fix it.
Understanding Query Dependencies
Visualize how your queries are connected using Query Dependencies.
Query Dependencies is a visual map in Power BI that shows how your queries are linked together. Useful for understanding data flow, troubleshooting, and optimizing.
When Is It Useful?
You are using multiple data sources (e.g., merging or appending queries).
You have created parameters, reference tables, or custom transformations.
You want to track relationships between original and transformed data.
Example: Using Your Sample Sales Data
Let us say:
You have 2 Excel tables loaded: Sales_2023 and Sales_2024.
You append them to form a single query: AllSales.
Then, you merge AllSales with another table (e.g., ProductDetails) to get full records.
You might also:
Add a parameter (like MinQuantity) to filter.
Reference one query from another for cleaner logic.
Step-by-Step to View Query Dependencies
Open Power BI Desktop
Go to Home > Transform Data to open Power Query Editor
Go to the top ribbon → click View > Query Dependencies
What You will See
You will see a flow diagram like this
Each box is a query
Each arrow shows a dependency
You can hover over each box to see a summary of that query’s structure.
Final Thoughts
These advanced Power Query techniques help turn raw data into clean, connected, and usable models for analysis. Mastering them not only improves efficiency—it builds your confidence to take on real-world Power BI projects.
Subscribe to my newsletter
Read articles from Bhargavi Adepu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Bhargavi Adepu
Bhargavi Adepu
Sharing practical guides and insights on Microsoft Fabric, Power BI, and modern analytics.