• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Dynamically Reference Named Column

Hi,

I am trying to automate a working template as much as I can to avoid editing PQ steps. I have named dataset_actual in the workbook to be edited by the user. In this case "ACTUAL2025" is the column I am trying to reference. However, this will change as the user toggles the workbook and we need power query to change smoothly in the steps. I have tried a few different ways.


1754332490145.png
 
One way:
Get your value in the named single cell dataset_actual as follows:
I chose to name the step ColmHdr:
Code:
ColmHdr = Table.FirstValue(Excel.CurrentWorkbook(){[Name="dataset_actual"]}[Content])
1754349162061.png
Then in the add column step use the likes of this:
Code:
= Table.AddColumn(Source, "Added Colm", each Record.Field(_ ,ColmHdr)  & " Hi!", type text)
Here I've used the leftmost column headed ColmHdr1:
1754349349464.png

Here I've opted for ColmHdr5:
1754349536916.png

I hope I've properly understood your question.
 
Back
Top