Power Query – Importing and Managing Data: Difference between revisions
												
				Jump to navigation
				Jump to search
				
No edit summary  | 
				|||
| (4 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
== Objective ==  | == Objective ==  | ||
Learn how to import data from different sources and manage query settings.  | |||
== Files Used ==  | == Files Used ==  | ||
| Line 12: | Line 12: | ||
== Importing Data from Excel ==  | == Importing Data from Excel ==  | ||
'''Steps:'''  | '''Steps:'''  | ||
# Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Workbook...'''  | # Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Workbook...'''  | ||
# Select '''Sales_January.xlsx  | # Select '''Sales_January.xlsx'''  | ||
# In the Navigator window, select the sheet and click '''Transform Data'''  | # In the Navigator window, select the sheet and click '''Transform Data'''  | ||
== Importing Data from CSV ==  | == Importing Data from CSV ==  | ||
| Line 22: | Line 20: | ||
# Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Text/CSV'''  | # Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Text/CSV'''  | ||
# Select '''Employees.csv'''  | # Select '''Employees.csv'''  | ||
#   | # Click '''Transform Data'''  | ||
== Importing from a Text File ==  | |||
'''Steps:'''  | |||
# Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Text/CSV'''  | |||
# Select '''ProductList.txt'''  | |||
# Set delimiter to '''Tab'''  | |||
# Click '''Transform Data'''  | |||
== Importing Multiple Excel Files ==  | == Importing Multiple Excel Files ==  | ||
'''Scenario:'''   | '''Scenario:''' Combine monthly files into one dataset.  | ||
'''Steps:'''  | '''Steps:'''  | ||
# Place   | # Place '''Sales_January.xlsx''' and '''Sales_February.xlsx''' in the same folder  | ||
# Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Folder'''  | # Go to the '''Data''' tab → '''Get Data''' → '''From File''' → '''From Folder'''  | ||
#   | # Select the folder and click '''Transform Data'''  | ||
# In Power Query Editor: click '''Combine''' → '''Combine & Transform Data'''  | |||
# In Power Query Editor:  | # Select the worksheet to use and confirm  | ||
#  | == Managing Queries ==  | ||
* Rename queries (right-click → '''Rename''')  | |||
* Duplicate queries (right-click → '''Duplicate''')  | |||
* View query dependencies: '''View''' tab → '''Query Dependencies'''  | |||
== Import Multiple CSV Files ==  | |||
'''Goal:''' Practice folder import using CSVs.  | |||
'''Steps:'''  | '''Steps:'''  | ||
#   | # Save a few copies of '''Employees.csv''' with small changes (e.g. Employees_1.csv, Employees_2.csv)  | ||
#   | # Place them in a folder  | ||
#   | # Use '''Get Data → From Folder''' to combine them  | ||
# Click '''  | # Filter only Active employees  | ||
# Load to a worksheet  | |||
== Create a Parameter for Folder Path ==  | |||
'''Goal:''' Make your folder import dynamic so the query works even if the folder path changes.  | |||
=== 1. Open Power Query Editor ===  | |||
If you're not already there:  | |||
* In Excel → '''Data''' tab → '''Queries & Connections'''  | |||
* Right-click your folder-based query → '''Edit'''  | |||
=== 2. Create the parameter ===  | |||
* In Power Query Editor → '''Home''' tab → '''Manage Parameters''' → '''New Parameter'''  | |||
* Fill in:  | |||
** Name: `ImportFolder`  | |||
** Type: Text  | |||
** Current Value: (paste the folder path you used originally)  | |||
* Click '''OK'''  | |||
=== 3. Replace the static path with the parameter ===  | |||
'''Option A: Source step'''  | |||
# In the Applied Steps pane → click ⚙ next to '''Source'''  | |||
# Replace the folder path with: `ImportFolder`  | |||
# Click '''OK'''  | |||
'''Option B: Advanced Editor'''  | |||
# Go to '''Home''' tab → '''Advanced Editor'''  | |||
# Find the line:  | |||
 Source = Folder.Files("C:\your\original\path")  | |||
# Replace with:  | |||
 Source = Folder.Files(ImportFolder)  | |||
# Click '''Done'''  | |||
==   | === 4. Load the result ===  | ||
* Go to '''Home''' → '''Close & Load To...'''  | |||
*   | * Choose whether to create a table, connection, or add to the Data Model  | ||
*   | |||
==   | === ✅ Result ===  | ||
You can now change the folder path in the parameter settings, and the query will update automatically.  | |||
----  | ----  | ||
Latest revision as of 09:49, 22 June 2025
Module 2: Importing and Managing Data
Objective
Learn how to import data from different sources and manage query settings.
Files Used
- Download Sales_January.xlsx
 - Download Sales_February.xlsx
 - Download Employees.csv
 - Download ProductList.txt
 
Importing Data from Excel
Steps:
- Go to the Data tab → Get Data → From File → From Workbook...
 - Select Sales_January.xlsx
 - In the Navigator window, select the sheet and click Transform Data
 
Importing Data from CSV
Steps:
- Go to the Data tab → Get Data → From File → From Text/CSV
 - Select Employees.csv
 - Click Transform Data
 
Importing from a Text File
Steps:
- Go to the Data tab → Get Data → From File → From Text/CSV
 - Select ProductList.txt
 - Set delimiter to Tab
 - Click Transform Data
 
Importing Multiple Excel Files
Scenario: Combine monthly files into one dataset.
Steps:
- Place Sales_January.xlsx and Sales_February.xlsx in the same folder
 - Go to the Data tab → Get Data → From File → From Folder
 - Select the folder and click Transform Data
 - In Power Query Editor: click Combine → Combine & Transform Data
 - Select the worksheet to use and confirm
 
Managing Queries
- Rename queries (right-click → Rename)
 - Duplicate queries (right-click → Duplicate)
 - View query dependencies: View tab → Query Dependencies
 
Import Multiple CSV Files
Goal: Practice folder import using CSVs.
Steps:
- Save a few copies of Employees.csv with small changes (e.g. Employees_1.csv, Employees_2.csv)
 - Place them in a folder
 - Use Get Data → From Folder to combine them
 - Filter only Active employees
 - Load to a worksheet
 
Create a Parameter for Folder Path
Goal: Make your folder import dynamic so the query works even if the folder path changes.
1. Open Power Query Editor
If you're not already there:
- In Excel → Data tab → Queries & Connections
 - Right-click your folder-based query → Edit
 
2. Create the parameter
- In Power Query Editor → Home tab → Manage Parameters → New Parameter
 - Fill in:
- Name: `ImportFolder`
 - Type: Text
 - Current Value: (paste the folder path you used originally)
 
 - Click OK
 
3. Replace the static path with the parameter
Option A: Source step
- In the Applied Steps pane → click ⚙ next to Source
 - Replace the folder path with: `ImportFolder`
 - Click OK
 
Option B: Advanced Editor
- Go to Home tab → Advanced Editor
 - Find the line:
 
Source = Folder.Files("C:\your\original\path")
- Replace with:
 
Source = Folder.Files(ImportFolder)
- Click Done
 
4. Load the result
- Go to Home → Close & Load To...
 - Choose whether to create a table, connection, or add to the Data Model
 
✅ Result
You can now change the folder path in the parameter settings, and the query will update automatically.
Return to Main Page
→ Continue to Module 3: Data Transformation Techniques