This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
Hi folks,
I have a table with very many columns. I am looking to build a function (fChange) that can be called on any column. It looks like this:
= (myTable as table, myColumn as text) => let
#"Replace Value" = Table.ReplaceValue( myTable, "some text", myTable[myColumn]{1} & " ccc", // change to text on row 2 and " ccc"
Replacer.ReplaceValue, {myColumn})
in
#"Replace Value"
The function is supposed to be called using :
=fChange(TableFromPreviousStep, "Column78")
myTable[myColumn]{1} reference in line 2 is not working. Power Query interprets myColumn not as variable, but as the column name "myColumn". I need to have variable column name there so that I can call the function on any column. What is correct syntax to reference a column in a variable in "M" function? Failed to google find answer on the net.
Solved! Go to Solution.
@gvg , you may want to try
= (myTable as table, myColumn as text) =>
let
#"Replace Value" = Table.ReplaceValue( myTable, "some text", Table.ToList(Table.SelectColumns(myTable, myColumn)){1} & " ccc", Replacer.ReplaceValue, {myColumn})
in
#"Replace Value"
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
@gvg , you may want to try
= (myTable as table, myColumn as text) =>
let
#"Replace Value" = Table.ReplaceValue( myTable, "some text", Table.ToList(Table.SelectColumns(myTable, myColumn)){1} & " ccc", Replacer.ReplaceValue, {myColumn})
in
#"Replace Value"
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |