SOLVED

Relinking Transform Sample File query with function in Power Query?

Brass Contributor

Hi all,

 

When transforming a sample file, e.g. as part of a Folder query, it really is neat that Power Query automatically creates a sample file parameter and especially a custom function that automatically updates when the corresponding query is updated.

However, I am now working with a file, where someone has decoupled the query and the function by editing directly in the Advanced Editor in the function. Hence, the function is no longer updated, when the query is changed. I've googled this for quite a while, and I see no solutions.

Do any of you know of any way to link these two again (and not having to create a new Folder query from scratch)? I do realize I can copy-paste my original m-code directly to the new Transform Sample File query, but it is quite a hassle, and messes up naming a bit, as it will then be Transform Sample File (2) etc.

Basically, I would love to be able to do the opposite of this:

 

TorbenKirkWolf_1-1625569493465.png

 

1 Reply
best response confirmed by Torben Kirk Wolf (Brass Contributor)
Solution

@Torben Kirk Wolf 

Hi,

I was just trying to resolve the same problem and came across your post.  I found a way to do it- Sort of...  It's a little clunky but works.  This was the only way I could determine to "relink" after searching forever online with no resolution so I figured I would pass it along.

  1. Open the "Transform Sample File" in the query editor.
  2. Once the editor opens right-click on "Transform Sample File" under the queries pane on the left. 
  3. In the pop-up menu click "Create Function".  You will have to name it something different than what it was previously.  Save. 
  4. Edit your main queries to replace the function reference(s) with the new function name.
  5. Optional Clean-up.  A new sub-folder is created by step 3.  If you want everything back to one folder just move the items in the new sub-folder into the original sub-folder and delete the new sub-folder once it's empty. Also delete the old disconnected function.      
1 best response

Accepted Solutions
best response confirmed by Torben Kirk Wolf (Brass Contributor)
Solution

@Torben Kirk Wolf 

Hi,

I was just trying to resolve the same problem and came across your post.  I found a way to do it- Sort of...  It's a little clunky but works.  This was the only way I could determine to "relink" after searching forever online with no resolution so I figured I would pass it along.

  1. Open the "Transform Sample File" in the query editor.
  2. Once the editor opens right-click on "Transform Sample File" under the queries pane on the left. 
  3. In the pop-up menu click "Create Function".  You will have to name it something different than what it was previously.  Save. 
  4. Edit your main queries to replace the function reference(s) with the new function name.
  5. Optional Clean-up.  A new sub-folder is created by step 3.  If you want everything back to one folder just move the items in the new sub-folder into the original sub-folder and delete the new sub-folder once it's empty. Also delete the old disconnected function.      

View solution in original post