Power Query Basics
Master the Power Query Editor for data transformation
What You'll Learn
- What Power Query is and why it matters
- Navigate the Power Query Editor
- Basic transformation operations
- Apply and close queries
What is Power Query?
Power Query is Power BI's built-in data cleaning and transformation tool.
Think of it as a powerful Excel on steroids for preparing data.
Why Use Power Query?
- Clean messy data
- Combine multiple sources
- Remove duplicates
- Split/merge columns
- Filter rows
- Change data types
Opening Power Query Editor
From Get Data: When importing data, click "Transform Data" instead of "Load"
From Power BI: Home > Transform Data
This opens the Power Query Editor window!
Power Query Interface
Top Section: Ribbon
Contains all transformation commands:
Home Tab:
- Remove rows/columns
- Keep/remove duplicates
- Split columns
- Change data types
Transform Tab:
- Text transformations
- Number operations
- Date/time functions
Add Column Tab:
- Create new columns
- Custom columns
- Conditional columns
Left: Queries Pane
Shows all your queries (data tables)
Center: Data Preview
See your data and transformations in real-time
Right: Query Settings
Properties: Query name
Applied Steps: Every transformation you make appears here! Click any step to see data at that point Delete steps by clicking X
Basic Transformations
Remove Columns
Remove unwanted columns:
- Select column header
- Right-click
- Choose "Remove" or "Remove Other Columns"
Filter Rows
Keep only rows you need:
- Click dropdown on column header
- Uncheck values to exclude
- Click OK
Number filters:
- Greater than
- Less than
- Between
Text filters:
- Contains
- Begins with
- Equals
Change Data Type
Fix data types:
- Click icon next to column name
- Select correct type:
- Text
- Whole Number
- Decimal Number
- Date
- True/False
Power BI auto-detects but might be wrong!
Rename Columns
Make names clearer:
- Double-click column header
- Type new name
- Press Enter
Or right-click > Rename
Remove Duplicates
Clean duplicate rows:
- Select column(s)
- Home > Remove Duplicates
Based on selected columns only!
Remove Top/Bottom Rows
Remove header rows or footers:
- Home > Remove Rows
- Choose:
- Remove Top Rows
- Remove Bottom Rows
- Remove Alternate Rows
Split Columns
Split "First Last" into two columns:
- Select column
- Home > Split Column
- Choose delimiter:
- By Delimiter (comma, space, etc.)
- By Number of Characters
- By Positions
Merge Columns
Combine "First" and "Last" into "Full Name":
- Select columns (hold Ctrl)
- Transform > Merge Columns
- Choose separator (space, comma, etc.)
- Name new column
Applied Steps
Every action creates a step!
Step Example:
- Remove column > "Removed Columns"
- Filter rows > "Filtered Rows"
- Change type > "Changed Type"
Why This Matters:
- See transformation history
- Edit/delete steps later
- Steps run in order!
Reorder Steps: Drag steps up/down (be careful!)
Close & Apply
When done transforming:
Home > Close & Apply
This:
- Saves transformations
- Closes Power Query
- Loads data into Power BI
- You're back in Report View!
Refresh Data
When source data changes:
Home > Refresh
Power Query re-runs all transformations automatically!
Try This Exercise
Clean Sample Data:
- Create Excel with messy data:
- Extra header rows
- Wrong data types
- Duplicate entries
- Unwanted columns
- Import to Power BI with "Transform Data"
- In Power Query:
- Remove top rows
- Delete unwanted columns
- Change data types
- Remove duplicates
- Close & Apply
- Verify clean data in Power BI!
Common Mistakes
Changing order of steps: Later steps depend on earlier ones!
Not renaming queries: Use clear names like "Sales_Clean" not "Query1"
Loading too much data: Filter early to improve performance
Best Practices
Always use Transform Data: Don't import messy data directly
Name your steps: Right-click step > Rename for clarity
Document with notes: Right-click query > Properties > add description
Test incrementally: Apply one transformation, check result, continue
Next Steps
Now let's dive deeper into specific data transformations!
Tip: Power Query is forgiving. If you mess up, just delete the step and try again!