Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
e17aguilar
Frequent Visitor

Using parameters in advanced editor

 

I'm wondering if I can replace a piece of code in the advanced editor with a parameter that contents the same piece of code on text value. For example, if I want to change the type of each column:

 

1) This is the line recorded by Power Query Editor, and I want to replace the bolded code with a parameter (because the numbers of columns can change, and also the columns name can change):

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers", {{""Etap"", Int64.Type}, {""Ser."", Int64.Type}, {""Bloq"", Int64.Type}}),

 

2) Then I create a text parameter, named Parameter1, with the following value:

 {{""Etap"", Int64.Type}, {""Ser."", Int64.Type}, {""Bloq"", Int64.Type}}

 

3) And try to replace the parameter in the advanced editor line (I'm not sure of the syntax):

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers", Parameter1),

 

4) But this error message is displayed:


Error.PNG

 

 

 

 

 

 

 

 

Let me know if there is any other way to replace a piece of code with something else instead of a parameter. Mainly because I have a variable number of columns in a query.

 

Thank you in advance for your help.

 

 

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @e17aguilar,

 

I don't think above attemption is achievable.

 

As you can see, the supported data type by Query Parameter are normal ones. 

1.PNG

 

But, many times, the items wrapped by Power Query function are not listed in above data types. In your example, the second argument in Table.TransformColumnTypes function should be List type. While the value ({{""Etap"", Int64.Type}, {""Ser."", Int64.Type}, {""Bloq"", Int64.Type}}) you passed by parameter was forced to Text. They are not matched, hence caused errors. Especially, the long text wrapped by "{ }" cannot be passed as a parameter value.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @e17aguilar,

 

I don't think above attemption is achievable.

 

As you can see, the supported data type by Query Parameter are normal ones. 

1.PNG

 

But, many times, the items wrapped by Power Query function are not listed in above data types. In your example, the second argument in Table.TransformColumnTypes function should be List type. While the value ({{""Etap"", Int64.Type}, {""Ser."", Int64.Type}, {""Bloq"", Int64.Type}}) you passed by parameter was forced to Text. They are not matched, hence caused errors. Especially, the long text wrapped by "{ }" cannot be passed as a parameter value.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.