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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Gerald23
Helper I
Helper I

Change column types dynamically

Hi Everyone,

 

I have an issue with changing column types in the Power Query Editor.  Normally i change them in the UI but this time my column names can change and there can be more or less columns in the data then currently is the case. So i wish to change all columns (Except the first 13 columns (They are always the same)) to the Currency type (Fixed Decimal Number). After some time on google I created the code below that doesn't have any syntax errors in the advanced editor however it gives me another error after pressing Done in the advanced editor.

 

ERROR:

Expression.Error: We cannot convert a value of type Table to type List.
Details:
    Value=[Table]
    Type=[Type]

 

This is the code i use in the advanced editor that gives above error

let
    Source = Csv.Document(Web.Contents("https://*******"),[Delimiter=",", Columns=179, Encoding=65001, QuoteStyle=QuoteStyle.None]),
    #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{Source,
      List.Transform(
          List.RemoveFirstN(
              Table.ColumnNames(Source),
              13
    ),
      each {_, Currency.Type}
    )})
      in
    #"Changed Type"

 

1 ACCEPTED SOLUTION
Jakinta
Solution Sage
Solution Sage

Your Changed Type step should be:

 

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",
      List.Transform(
          List.RemoveFirstN(
              Table.ColumnNames(Source),
              13
    ),
      each {_, Currency.Type}
    ))

 

View solution in original post

4 REPLIES 4
Jakinta
Solution Sage
Solution Sage

Your Changed Type step should be:

 

#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",
      List.Transform(
          List.RemoveFirstN(
              Table.ColumnNames(Source),
              13
    ),
      each {_, Currency.Type}
    ))

 

Hi, great solution!

Only, I'd like to know, how to use this 'List.Transform'-function with regional code (for instance "en-US" in case the system is not in US-american setting) - how to get this into the List.Transform-function?

 

Thanks in advance,

RaiSta

... just found the answer by chance...:

= Table.TransformColumnTypes(>table<, List.Transform(>List-of-columnheads<, each {_, Number.Type}), "en-US")

Tested and this works thanks for the help 🙂

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.