// fnGetParameter function written by Ken Puls, FCPA, FCMA, MS MVP (Excel)

// To use the function you must have a table called "Parameters" in your workbook
// The header row must contain a "Parameter" and a "Value" column (with those names)

// Data rows should list the paramter name in the first column and the value of that
// parameter in the second column

// Provided you save this query under the name "fnGetParameter", you can then reference
// it from other queries as follows:
//
//  =fnGetParameter("your_parameter_name")

// One useful sample to return the current folder:
// Parameter Name:	File Path
// Parameter Value:
//   For Excel 2019 & Prior:	=IFERROR(LEFT(CELL("filename",A1),FIND("[",CELL("filename",A1),1)-1),"Workbook needs to be saved!")
//   For Excel 365:		=LET(filepath,CELL("filename",A1),IFERROR(LEFT(filepath,FIND("[",filepath,1)-1),"Workbook needs to be saved!"))

// Call as  "fnGetParamater("File Path")

( getValue as text ) =>
let
    ParamTable = Excel.CurrentWorkbook(){[Name="Parameters"]}[Content],
    Result = ParamTable{[Parameter=getValue]}?[Value]?
in
    Result
