- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

How to pass column name as parameter into a function
Hello,
I need some help understanding how to pass a column name as parameter into a custom function.
I have a table (Accounts) from which I need a specific column (No) using a function that will filter that column.
@wdx223_Daniel was kind enough to help me getting the M code for filtering information in that table into another post: Power Query Select rows between two TEXT values
Now I have (partially) failed to create a custom function from his code, because the table name and column name will not be the same every time.
The code should be like this:
let
func = (srcTable as table, srcColumn as text, strStartWith as text, strEndWith as text) as list =>
let
Source = srcTable,
Pas1 = Table.Column(
Table.SelectRows(
Source,
each
let
fx = (txt1, txt2) =>
List.Count(Text.Split(txt1, ".")) = List.Count(Text.Split(txt2, "."))
and
Text.Remove(txt1, ".") <= Text.Remove(txt2, ".")
in
fx(strStartWith, srcColumn) and fx(srcColumn, strEndWith)
),
srcColumn
)
in
Pas1
in
func
My problem seems to be on the following line:
fx(strStartWith, srcColumn) and fx(srcColumn, strEndWith)
If instead of the parameter srcColum, represeting the source column from the source table (srcTable) that I have to filter & return as list I will put the real name of the column ([No]) as this:
fx(strStartWith, [No]) and fx([No], strEndWith)
...the code will work perfectly, and will return the expected data.
So, Is there a way to pass the column name as parameter?
Kind Regards,
Lucian
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

After some more digging, I find the answer => Record.Field(_,srcColumn).
So, changing the following line from:
fx(strStartWith, srcColumn) and fx(srcColumn, strEndWith)
to
fx(strStartWith, Record.Field(_,srcColumn)) and fx(Record.Field(_,srcColumn), strEndWith)
Will make the code work.
Kind Regards,
Lucian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

After some more digging, I find the answer => Record.Field(_,srcColumn).
So, changing the following line from:
fx(strStartWith, srcColumn) and fx(srcColumn, strEndWith)
to
fx(strStartWith, Record.Field(_,srcColumn)) and fx(Record.Field(_,srcColumn), strEndWith)
Will make the code work.
Kind Regards,
Lucian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

Thanks, this solved a problem for me 🙂

Helpful resources
Join our Fabric User Panel
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Power BI Monthly Update - June 2025
Check out the June 2025 Power BI update to learn about new features.

Subject | Author | Posted | |
---|---|---|---|
12-09-2023 05:50 AM | |||
03-30-2023 04:13 PM | |||
09-26-2024 12:14 PM | |||
02-23-2025 05:42 AM | |||
05-23-2025 08:02 AM |
User | Count |
---|---|
15 | |
12 | |
8 | |
8 | |
7 |
User | Count |
---|---|
15 | |
13 | |
7 | |
7 | |
6 |