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

Bhargavi AdepuBhargavi Adepu
8 min read

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.

  1. Load two Excel tables (e.g., Sales Data and Region Info) into Power BI.

  2. Go to Power Query Editor via Home > Transform Data.

  3. To merge: Select Merge Queries, choose key columns (e.g., Region), pick a join type (e.g., Left Join), and confirm.

  4. To append: Use Append Queries to stack rows from different datasets.

  5. Click Close & Apply to finalize your changes.

Creating Parameters

Parameters allow you to make transformations dynamic—perfect for filtering data or setting file paths.

  1. Load Excel table (e.g., Sales Data) into Power BI.

  2. In Power Query Editor, go to Manage Parameters > New Parameter.

  3. Give it a name (e.g., MinQuantity) and set its type and default value.

FieldValue
NameMinQuantity
DescriptionMinimum quantity for filtering sales
TypeDecimal Number or Whole Number
Suggested ValuesList of Values (e.g., 1, 5, 10, 25) or Any Value
Default Value5
Current Value5
  1. 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

  2. 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.

  1. In Power BI, go to Home > Transform data.

  2. Select a column like Region or Product.

  3. Click Transform > Group By.

  4. Choose the grouping column and set the operation

    • Group by: Product

    • New column name: Total Quantity

    • Operation: Sum

    • Column: Quantity

  5. 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.

  1. Select the Product column.

  2. Go to Transform > Replace Values.

  3. In the box:

    • Value To Find: laptop

    • Replace With: Laptop

  4. 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.

  1. Select the Customer Name column.

  2. Click Transform > Split Column > By Delimiter.

  3. Choose Space as delimiter (to separate first and last names).

  4. 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.

  1. Select the Customer Name column.

  2. 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.

  1. When a column shows errors, click the error icon to investigate.

  2. Use Remove Errors or Replace Errors from the Home tab.

  3. For advanced logic, use try...otherwise in a custom column.

Simulate an Error (for practice)

Load the Excel File into Power BI

  1. Open Power BI Desktop.

  2. Click Home > Get Data > Excel.

  3. Select the file Sample_Error_Data.xlsx.

  4. Choose the sheet (e.g., Sheet1) and click Load.

  5. 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

  1. Click the column with errors (e.g., Quantity).

  2. Go to Home > Remove Rows > Remove Errors.

  3. This deletes only the rows that contain errors in that column.

Option B: Replace Errors

  1. Click the column with errors (e.g., Unit Price).

  2. Go to Transform > Replace Errors.

  3. Enter a default value like 0 or 1000.

Option C: Use try...otherwise

This method handles errors during calculations.

  1. Go to Add Column > Custom Column.

  2. Name the column: Sales

  3. Use this formula:

  4. powerquery

  5. CopyEdit

  6. 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

  1. Open Power BI Desktop.

  2. Click Home > Get Data > Excel.

  3. Select your previous file (e.g., Sample_Sales_Data.xlsx) and load the sheet.

  4. Click Transform Data to open Power Query Editor.

Perform Transformations

Apply the following changes (just for practice):

  1. Change Data Type:

    • Set Order Date to Date type.

    • Set Quantity and Unit Price to Whole Number or Decimal Number.

  2. Add Custom Column:

    • Go to Add Column > Custom Column.

    • Name it Total Sales

Formula: [Quantity] * [Unit Price]

  1. 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

  1. Open Power BI Desktop

  2. Go to Home > Transform Data to open Power Query Editor

  3. 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.

0
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.