Forum Discussion

renee_crozier's avatar
renee_crozier
Brass Contributor
May 12, 2025

Power Query M Code Not Working When Pasting Into Another Workbook

I have some code that I wrote in Notepad++ basically creating a list and doing a mass find and replace on a column. I pasted it into the Advanced Editor, modified the steps calls, and it worked.

The code (adjusted for posting in this forum):

#"Changed Type" = Table.TransformColumnTypes(Source,{{"Current Value", type text}}),
#"AllReplace" = [#"V1" = "Value 1",
                 #"V2" = "Value 2"],
#"Replaced Value" = Table.TransformColumns(#"Changed Type",{{"Current Value",each Record.FieldOrDefault(AllReplace,_,_)}})

 

When I went to paste the code in a new workbook, the code did not work despite everything being the same. 

This isn't the first time I've had this issue with pasting in code. Previously, it's just been a bunch of Replace Values steps with no special adjustments to them that I didn't want to recreate in each workbook.

 

What's going on? Any assistance would be amazing here.

2 Replies

    • renee_crozier's avatar
      renee_crozier
      Brass Contributor

      Thank you for sending this over. I read over the article and downloaded Visual Studio and installed the Power Query M extension. After pasting in my actual code, I'm not seeing any holes where it wouldn't work and I'm not getting any error messages. It's simply just not doing anything.

Resources