Web Hosting Blog by Nest Nepal | Domain & Hosting Tips

How to Use Power Query Editor Effectively

Power Query Editor is like the Swiss Army knife of data preparation in Power BI. It’s where messy, real-world data gets transformed into something actually usable for analysis. But here’s the thing – most people barely scratch the surface of what this tool can do.

power-query-editor

If you’re still manually cleaning data in Excel before importing it into Power BI, you’re doing it wrong. Let me show you how to use Power Query like a pro.

What Power Query Editor Actually Does

Think of Power Query as your data janitor, data translator, and data architect all rolled into one. It:

  • Connects to virtually any data source
  • Cleans and transforms messy data
  • Combines data from multiple sources
  • Automates repetitive data prep tasks
  • Refreshes everything automatically

The best part? Everything you do creates steps that can be repeated every time your data refreshes. No more manual cleanup every month.

Getting Started: The Interface Tour

When you click “Transform Data” in Power BI, you’re entering Power Query Editor. Here’s what you’re looking at:

Left Pane: Queries – all your data sources and transformations 

Center: Data preview – what your data looks like right now 

Right Pane: Query Settings – shows all the steps you’ve applied 

Top Ribbon: All the transformation tools

The magic happens in that Applied Steps section on the right. Every action becomes a step that Power Query remembers and repeats.

Essential Data Cleaning Operations

1. Remove Junk Rows and Columns

Most real data has header rows, footer totals, or empty columns you don’t need.

Remove empty columns: Home tab → Remove Columns → Remove Empty Columns 

Remove top rows: Home tab → Remove Rows → Remove Top Rows 

Remove blank rows: Home tab → Remove Rows → Remove Blank Rows

Pro tip: Always remove junk before doing other transformations. It’s faster and cleaner.

2. Fix Column Headers

Your column headers probably suck. They’re either “Column1, Column2” or something like “Q1_2024_Sales_Amount_USD_Final_v2”.

Promote first row to headers: Home tab → Use First Row as Headers Manually rename: Double-click any column header and type the new name

3. Change Data Types (The Right Way)

Power Query often guesses data types wrong. Here’s how to fix it:

Data TypeWhen to UseCommon Issues
TextIDs, codes, zip codesNumbers that shouldn’t be calculated
Whole NumberCounts, quantitiesRemoves decimals if applied wrong
Decimal NumberPrices, percentagesGood for most numeric data
DateDates (obviously)Regional format confusion
Date/TimeTimestampsTime zone issues

Quick tip: Select multiple columns and change data type for all at once. Much faster than doing them one by one.

4. Handle Missing Values

Real data has gaps. Here’s how to deal with them:

Replace null values: Right-click column → Replace Values → leave “Value to Find” empty, enter replacement Remove rows with nulls: Home tab → Remove Rows → Remove Blank Rows Fill down: Right-click column → Fill → Down (copies value from above)

Text Transformation Magic

Split Columns Like a Pro

Got a “Full Name” column that should be “First Name” and “Last Name”? Or addresses all mashed together?

Split by delimiter: Select column → Home tab → Split Column → By Delimiter Split by character positions: Split Column → By Number of Characters Split by uppercase: Split Column → By Uppercase to Lowercase

Extract and Clean Text

Remove extra spaces: Transform tab → Format → Trim Change case: Transform tab → Format → Uppercase/Lowercase/Proper Case Extract numbers only: Transform tab → Extract → Text Before/After Delimiter

Real example: Cleaning product codes like “PROD-12345-XL” to extract just “12345”:

  1. Split by delimiter “-“
  2. Keep only the middle column
  3. Change data type to number

Date and Time Transformations

Working with dates in Power Query is actually pretty smooth once you know the tricks.

Parse Dates from Text

If your dates are stored as text like “20240315” or “Mar-15-2024”:

  1. Select the column
  2. Transform tab → Date → Parse
  3. Choose the format that matches your data

Extract Date Parts

Want separate columns for Year, Month, Quarter?

  1. Select your date column
  2. Add Column tab → Date → Year/Month/Quarter/Day
  3. Power Query creates new columns with extracted values

Create Date Ranges

Add days: Add Column → Custom Column → [YourDate] + #duration(30,0,0,0) (adds 30 days) First day of month: Transform tab → Date → Beginning of Month Last day of month: Transform tab → Date → End of Month

Combining Data Sources

This is where Power Query really shines. You can merge data from completely different sources.

Merge Queries (Like VLOOKUP but Better)

Say you have sales data and want to add customer information:

  1. Home tab → Merge Queries
  2. Select the matching columns from both tables
  3. Choose join type (usually Left Outer)
  4. Expand the merged column to get the fields you want

Join types explained:

  • Left Outer: Keep all rows from left table
  • Inner: Only rows that match in both tables
  • Full Outer: All rows from both tables

Append Queries (Stack Tables)

Got multiple files with the same structure? Stack them:

  1. Home tab → Append Queries
  2. Select which queries to combine
  3. Power Query matches columns by name

Common use case: Monthly sales files that you want to combine into one dataset.

Advanced Techniques That Save Hours

Custom Columns with Conditional Logic

Add Column tab → Custom Column lets you write formulas:

if [Sales Amount] > 1000 then “High Value” 

else if [Sales Amount] > 500 then “Medium Value” 

else “Low Value”

Group By Operations

Transform tab → Group By is like a pivot table:

  • Group by Category
  • Sum the Sales Amount
  • Count the number of transactions

Unpivot Columns

Got data in wide format (months as columns) but need it in long format? Select the month columns → Transform tab → Unpivot Columns.

Before: Product A | Jan | Feb | Mar After: Product A | Month | Value (with separate rows for each month)

Working with Files and Folders

Combine Multiple Excel Files

This is a game-changer if you get monthly Excel files:

  1. Get Data → Folder
  2. Choose the folder with your files
  3. Filter to only Excel files
  4. Combine & Transform Data
  5. Power Query automatically stacks all sheets

Handle Different File Structures

If your files don’t have identical structures:

  1. Add custom columns to identify source files
  2. Use conditional logic to handle variations
  3. Standardize column names before combining

Performance Tips That Actually Work

1. Do Heavy Operations Early

Filter out unnecessary rows and columns as early as possible. Don’t wait until the end.

2. Avoid Repeated Calculations

If you’re doing the same calculation multiple times, create a custom column once and reference it.

3. Use Native Connectors

Always use the specific connector (SQL Server, SharePoint, etc.) instead of generic ODBC when possible.

4. Minimize Data Types

Don’t load text as numbers or dates if you’re not doing calculations. Text is faster.

Error Handling and Debugging

Common Errors and Quick Fixes

“DataFormat.Error”: Usually a data type conversion issue

  • Check for unexpected characters in numeric columns
  • Look for different date formats mixed together

“Expression.Error”: Problem with a custom formula

  • Break complex formulas into multiple steps
  • Check column names for typos

“DataSource.Error”: Connection or permission issue

  • Verify data source is accessible
  • Check credentials and permissions

Debugging Strategies

  1. Use the step-by-step approach: Click through each Applied Step to see where things break
  2. Create duplicate queries: Test changes on a copy before modifying the original
  3. Add custom columns for debugging: Create columns showing intermediate calculations

Power Query Formula Language (M) Basics

You don’t need to be an M expert, but knowing these basics helps:

// This is a comment

let

    Source = Excel.Workbook(…),

    Sheet1 = Source{[Name=”Sheet1″]}[Data],

    FilteredRows = Table.SelectRows(Sheet1, each [Amount] > 1000)

in

    FilteredRows

Key concepts:

  • let…in structure for all queries
  • each refers to current row
  • Table. functions work on entire tables
  • Everything is case-sensitive

Real-World Workflow Example

Here’s how I typically approach a messy dataset:

  1. First pass – Remove junk: Empty columns, header rows, footer totals
  2. Fix structure: Column names, data types, split/merge columns as needed
  3. Clean data: Handle nulls, trim text, standardize formats
  4. Add business logic: Calculated columns, conditional logic, groupings
  5. Final cleanup: Remove helper columns, reorder columns logically

Best Practices for Team Environments

Document Your Steps

Add descriptions to complex steps: Right-click step → Properties → Description

Use Consistent Naming

  • Queries: “Sales_Raw”, “Sales_Cleaned”, “Sales_Final”
  • Steps: “Remove Empty Columns”, “Filter Recent Data”
  • Columns: Use clear, consistent naming conventions

Handle Data Source Changes

  • Use parameters for file paths and server names
  • Document data source requirements
  • Test with different data scenarios

Common Mistakes to Avoid

Mistake 1: Not Understanding Data Refresh

Power Query steps run every time data refreshes. Don’t hard code dates or specific values that will become invalid.

Mistake 2: Over-Engineering

Keep it simple. Complex M code is hard to maintain and debug.

Mistake 3: Ignoring Performance

Loading millions of rows just to filter to hundreds is wasteful. Filter early and often.

Mistake 4: Not Testing Edge Cases

What happens when a file is missing? When is a column empty? Test these scenarios.

Quick Reference: Most-Used Operations

TaskLocationWhat It Does
Remove ColumnsHome → Remove ColumnsDelete unwanted columns
Change Data TypeHome → Data Type dropdownFix how data is interpreted
Replace ValuesRight-click column → Replace ValuesFind and replace text/values
Split ColumnHome → Split ColumnBreak one column into multiple
Merge QueriesHome → Merge QueriesJoin data from different sources
Group ByTransform → Group ByAggregate data like pivot tables
Custom ColumnAdd Column → Custom ColumnAdd calculated fields

The Bottom Line

Power Query Editor is incredibly powerful, but you don’t need to master everything at once. Start with basic cleaning operations, get comfortable with the interface, then gradually add more advanced techniques.

The key is understanding that every action becomes a repeatable step. This means the hour you spend setting up proper data cleaning saves you hours every month when the data refreshes.

Stop doing manual data prep. Let Power Query do the heavy lifting while you focus on actual analysis.

Share this article
Shareable URL
Prev Post

Understanding DAX (Data Analysis Expressions) with Simple Examples

Next Post

Predictive Analysis Using Power BI

Leave a Reply

Your email address will not be published. Required fields are marked *

Read next