Forum Discussion

e17aguilar's avatar
e17aguilar
Frequent Visitor
8 years ago
Solved

Variable code in advanced editor

I'm wondering if I can replace a piece of code in the advanced editor with a parameter (or something else) that contents the same piece of code. For example, if I want to change the type of each colu...
  • v-danhe-msft's avatar
    8 years ago

    Hi e17aguilar,

    Based on my test, you could refer to below steps:

    Create the parameter in the query editor and just enter the column name like the picture below:

    Modify the code in the advanced language:

    Now you could see the result.

     

    Regards,

    Daniel He

  • e17aguilar's avatar
    e17aguilar
    8 years ago

    Hi Daniel,

     

    Many thanks for your help. You helped me to unterstand that I should use a variable list instead of a parameter. 

     

    I continued my research with this idea on mind, and I found this post, by THE BICCOUNTANT:

     

    https://www.thebiccountant.com/2017/01/09/dynamic-bulk-type-transformation-in-power-query-power-bi-and-m/

     

    They explain in a very short and simple way how to dynamically change the type from each column in a table, using a list that contains the name of all columns from the queried table.

     

    Kind regards, 

    Ernesto J. Aguilar