Power Query – Automation and Parameters: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 31: | Line 31: | ||
You can reference parameters directly in the formula bar or Advanced Editor. Example: | You can reference parameters directly in the formula bar or Advanced Editor. Example: | ||
= Table.SelectRows(Source, each [Currency] = TargetCurrency) | = Table.SelectRows(Source, each [Currency] = TargetCurrency) | ||
== Using Parameters for File Paths == | == Using Parameters for File Paths == |
Revision as of 09:14, 19 June 2025
Module 4: Automation and Parameters
Objective
In this module, you'll learn how to automate tasks using query parameters and load data dynamically.
Files Used
What Are Parameters?
Parameters let you store a value (like a currency code or file path) and reuse it in queries. They’re useful for automating imports and applying dynamic filters.
Creating a Parameter
Steps:
- In Power Query Editor, go to the Home tab → Manage Parameters → New Parameter
- Fill in the fields:
- Name: e.g. `TargetCurrency`
- Type: Text
- Suggested Values: Any value (or a list, if preferred)
- Current Value: e.g. `EUR`
- Click OK
Using a Parameter in a Filter
Steps:
- Load ExchangeRates.xlsx into Power Query
- Select the column Currency
- Go to the Home tab → Keep Rows → Keep Rows Where...
- Choose: Column Currency equals parameter TargetCurrency
Using a Parameter in M Code
You can reference parameters directly in the formula bar or Advanced Editor. Example:
= Table.SelectRows(Source, each [Currency] = TargetCurrency)
Using Parameters for File Paths
Scenario: You want to dynamically load a file based on a path stored as a parameter.
Steps:
- Create a Text parameter, e.g. `FilePath`
- Go to the Home tab → New Source → Excel Workbook
- In the file dialog, use the value from the parameter
- If needed, open the Advanced Editor and replace static path with `FilePath`
Automating Folder Imports
Steps:
- Go to the Data tab → Get Data → From File → From Folder
- Select a folder containing multiple files (e.g. sales reports)
- Click Transform Data
- Power Query will open a preview — click Combine → Combine & Transform Data
- Use a parameter for the folder path if needed (replace in Advanced Editor or via formula bar)
→ Continue to Module 5: Power Pivot Overview
Return to Main Page