Hello,
I'd be grateful for some PQ Parameter help, please.
I'm planning to distribute a workbook that applies a number of queries based on files in a Dropbox folder, to a number of teams. Because the teams will have different Dropbox paths and may give their source workbooks different names, I've set up a Parameter table to enable each team to set up their particular paths and names. The relevant M-code is:
Source = Folder.Files(#"fnGetParameter"("Dropbox path")),
#"Filtered Rows" = Table.SelectRows(Source, each [Name] = #"fnGetParameter"("Visit tracker name"),
So far, so good, but I'd like to make the parameter function (fnGetParameter) case-insensitive so that it will work regardless of how the parameter is entered in the table. In other words, if the source workbook is called Visits.xlsx, I want it still to work if the parameter is entered as "visits.xlsx" etc. The code for the function is:
let
Source = (ParameterName as text) =>
let
ParamSource = Excel.CurrentWorkbook(){[Name="tblTrackerParameters"]}[Content],
ParamRow = Table.SelectRows(ParamSource, each ([Description] = ParameterName)),
Value=
if Table.IsEmpty(ParamRow)=true
then null
else Record.Field(ParamRow{0},"Value")
in
Value
in
Source
I had thought about using Comparer.OrdinalIgnoreCase, but Table.SelectRows doesn't seem to support it. Can you possibly help?
Thanks very much.
Pieter
... I should add that I had also thought about adding some VBA to convert the parameter values to lowercase in the Parameter table and then adding a transformation in the query to convert all file names to lowercase before selecting the rows. This might work but seems like a double fudge! I'm also keen to make the team workbooks macro-free if at all possible.
Pieter