Skip to content

Parameter Tables

A parameter table holds settings in a worksheet, where anyone can change them, and Power Query reads them from there instead of from values fixed in its code.

A typical case is a file path. Suppose the production accountant at a small film and TV company keeps a workbook that combines the weekly cost reports for each production. The reports sit in a folder called Weekly Cost Reports, and the query that reads them was written with the full path on the accountant’s laptop. When the workbook is copied to the shared drive, or handed to a colleague, the path no longer exists and the query fails.

A parameter table solves this in two ways. The folder can be worked out from wherever the workbook is saved, so the workbook finds its reports on any machine. Other settings, such as which production to report on and the week to report up to, move out of the M code and into cells that anyone can edit.

The method has three stages:

  1. Create a table of settings in Excel.
  2. Create a query that turns the table into a single record.
  3. Read the settings from that record in the queries that need them.
  • On a sheet of its own, create a table with two columns, Setting and Value, and name the table Settings in the Table Name box on the Table Design tab.
  • Enter one setting per row:
Setting Value
WorkbookFolder C:\Users\Accounts\Productions\
ReportsSubfolder Weekly Cost Reports\
Production The Lantern Keepers
CutOffDate 28/11/2026

The WorkbookFolder value is not typed in. It is a formula that returns the folder holding the workbook:

=TEXTBEFORE(CELL("filename",$A$1),"[")

CELL("filename",$A$1) returns the workbook’s full name in the form C:\Users\Accounts\Productions[Cost Tracker.xlsx]Settings, and TEXTBEFORE keeps everything before the opening bracket, which is the folder with its trailing backslash. The formula recalculates whenever the workbook is opened, so the value follows the workbook wherever it is saved.

Each setting name must be unique, because the names become field names in the next stage. They are also case-sensitive there, so CutOffDate and CutoffDate are different settings.

Create a query that reads the table and returns its settings as one record, with a field for each row:

  • On Excel’s Data tab, choose Get Data, then From Other Sources, then Blank Query.
  • On the Home tab of the Power Query Editor, choose Advanced Editor, and replace the code with the following:
let
Source = Excel.CurrentWorkbook(){[Name="Settings"]}[Content],
Settings = Record.FromList(Source[Value], Source[Setting])
in
Settings
  • Click Done, and rename the query Settings.
  • On the Home tab, choose Close & Load To, and then Only Create Connection, so that the record is not loaded back into a worksheet.

Excel.CurrentWorkbook() lists the tables in the open workbook, and {[Name="Settings"]}[Content] picks out the one named Settings. Source[Value] and Source[Setting] each return one column of that table as a list, and Record.FromList pairs them up, so the first value is stored under the first name, the second under the second, and so on. The result is a record like this:

Field Value
WorkbookFolder C:\Users\Accounts\Productions\
ReportsSubfolder Weekly Cost Reports\
Production The Lantern Keepers
CutOffDate 28/11/2026 00:00:00

The cut-off date arrives as a date and time, because Excel stores every date as a number of days and Excel.CurrentWorkbook returns it as a datetime. The query that uses it converts it back to a date.

If two rows share a setting name, Record.FromList fails with an error, which is the right outcome: a duplicate setting is a mistake to fix in the table, not something to resolve silently.

Any query in the workbook can now refer to a setting by name, as Settings[ReportsSubfolder] or Settings[CutOffDate]. The query below combines the weekly cost reports, each a CSV file with the columns WeekEnding, Production, Supplier and Amount:

let
ReportsFolder = Settings[WorkbookFolder] & Settings[ReportsSubfolder],
CutOff = Date.From(Settings[CutOffDate]),
ChosenProduction = Record.FieldOrDefault(Settings, "Production", null),
Source = Folder.Files(ReportsFolder),
CsvFiles = Table.SelectRows(Source, each Text.Lower([Extension]) = ".csv"),
Parsed = Table.AddColumn(CsvFiles, "Data", each Table.PromoteHeaders(Csv.Document([Content]), [PromoteAllScalars=true])),
Combined = Table.Combine(Parsed[Data]),
Typed = Table.TransformColumnTypes(Combined, {{"WeekEnding", type date}, {"Production", type text}, {"Supplier", type text}, {"Amount", type number}}, "en-GB"),
UpToCutOff = Table.SelectRows(Typed, each [WeekEnding] <= CutOff),
ForProduction = if ChosenProduction = null then UpToCutOff else Table.SelectRows(UpToCutOff, each [Production] = ChosenProduction)
in
ForProduction

The first three steps read the settings, and the rest of the query uses them in place of fixed values:

  • ReportsFolder joins the workbook’s folder and the subfolder into one path, which Folder.Files lists.
  • CutOff turns the cut-off date back into a date, so it can be compared with the WeekEnding column.
  • ChosenProduction uses Record.FieldOrDefault, which returns null rather than an error when the record has no Production field. A blank Value cell also comes through as null. Either way, the last step then keeps every production instead of filtering to one.

With the settings shown in the first stage, the query returns the costs of The Lantern Keepers up to the week ending 28 November 2026:

WeekEnding Production Supplier Amount
14/11/2026 The Lantern Keepers Hartwell Lighting 24,600.00
14/11/2026 The Lantern Keepers Kestrel Catering 3,180.00
21/11/2026 The Lantern Keepers Ashby Camera Hire 41,250.00
28/11/2026 The Lantern Keepers Hartwell Lighting 18,900.00

To report on Quarry Lane up to a later week, change the two cells in the Settings table and refresh. The M code does not change.

A settings table, read into a single record, lets every query in a workbook take its folder paths, dates and filters from cells rather than from its code. Because the folder is worked out from wherever the workbook is saved, the workbook can be copied to another machine or a shared drive, and its queries still find their source files.