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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
MBreden
Helper I
Helper I

ColumnNames with Datatypes

Hi all,

 

how can I combine dynamic ColumnNames with datatypes?

 

For example:

= Table.TransformColumnTypes(#"Ersetzter Wert",{{"FAP", Currency.Type}, {"BLP", Currency.Type}, {"Sales", Int64.Type}})

 

Thank you for every suggestion!

Melanie

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

Hello @MBreden  Melanie

 

find herewith enclosed an example how this could work out. The easy task to extract the columnnames, but I don't know how you thought how to detect the correct type for every column. But maybe you get an idea how it could work out

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUTKxMDQyBtKmSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t, Date = _t, Currency = _t]),
    ColumnNames = Table.ColumnNames(Source),
    Types = {type number, Int64.Type, Currency.Type},
    Zip = List.Zip({ColumnNames, Types}),
    AdaptTypes = Table.TransformColumnTypes(Source, Zip)
in
    AdaptTypes

 

Copy paste this code to the advanced editor to see how the solution works

If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun

Jimmy

View solution in original post

6 REPLIES 6
Jimmy801
Community Champion
Community Champion

Helllo @MBreden 

 

You can create a nested list with ColumnName and data type in it. If you can prepare such a list you can hand it over to the function in your example. Or It's your question more like "how do I identify dynamically the data type of my column?"


If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun

Jimmy

Hello Jimmy,

 

thank you for your answer!

Just right, I need a nested list of ColumnNames and data types to insert into the function.
But I don't know how to create it 🙄
Can you give me an example?

Melanie

Jimmy801
Community Champion
Community Champion

Hello @MBreden  Melanie

 

find herewith enclosed an example how this could work out. The easy task to extract the columnnames, but I don't know how you thought how to detect the correct type for every column. But maybe you get an idea how it could work out

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlXSUTKxMDQyBtKmSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Number = _t, Date = _t, Currency = _t]),
    ColumnNames = Table.ColumnNames(Source),
    Types = {type number, Int64.Type, Currency.Type},
    Zip = List.Zip({ColumnNames, Types}),
    AdaptTypes = Table.TransformColumnTypes(Source, Zip)
in
    AdaptTypes

 

Copy paste this code to the advanced editor to see how the solution works

If this post helps or solves your problem, please mark it as solution.
Kudos are nice to - thanks
Have fun

Jimmy

Thanks Jimmy,

 

I will try to adapt the code to my query

 

Melanie

Jimmy801
Community Champion
Community Champion

Hello @MBreden 

were you able to solve the problem with any reply given?

If so, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

All the best

Jimmy

Jimmy801
Community Champion
Community Champion

Hey Melanie

 

okay, give it a try and update us on this regard

 

good luck

 

Jimmy

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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