cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper III
Helper III

Change columns name

Hi,

 

When I try to get data through power query (from google sheets or excel file)

 

I get it by columns - and then ther is automatically change type activated (for example column with title "1")

 

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{" 1 ", type any},....

 

If later I will change my name column in data file to another title then "1" it will break the connection. 

 

So how can I figure this problem?

 

Thanks !

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Change columns name

Remove the #"Changed Type" step.

 

If you still need to type your data, then there are various ways to do it dynamically, depending on your specific situation and requirements.

Specializing in Power Query Formula Language (M)

View solution in original post

5 REPLIES 5
Highlighted
Community Champion
Community Champion

Re: Change columns name

Remove the #"Changed Type" step.

 

If you still need to type your data, then there are various ways to do it dynamically, depending on your specific situation and requirements.

Specializing in Power Query Formula Language (M)

View solution in original post

Highlighted
Helper III
Helper III

Re: Change columns name

Thanks,

if you still need to type your data, then there are various ways to do it dynamically, depending on your specific situation and requirements.

 

 

Can you tell me how or refer to specific link to learn about it?

 

 

 

Highlighted
Community Champion
Community Champion

Re: Change columns name

A typical example is to create a list with column names and the required types (this is actually a list of lists) and use that as second argument to function Table.TransformColumnTypes.

 

In this example, Table1 has 3 columns with a whole number, text and date. The query will still run if column names are adjusted.

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ColumnNames = Table.ColumnNames(Source),
    ColumnTypes = {Int64.Type, type text, type date},
    TransformSpecs = List.Zip({ColumnNames,ColumnTypes}),
    #"Changed Type" = Table.TransformColumnTypes(Source,TransformSpecs)
in
    #"Changed Type"

 

In the "hard coded" version you can also recognize the list of lists as second argument:

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Text", type text}, {"Date", type date}})
in
    #"Changed Type"

 

Specializing in Power Query Formula Language (M)
Highlighted
Helper III
Helper III

Re: Change columns name

Awesome

 

Thanks!

Highlighted
Frequent Visitor

Re: Change columns name

Hi Recoba

 

Did you change the column name dynamically without visual break? if yes please let me know the steps.

 

 

Thanks

Vannikannan.k

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors