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
Anonymous
Not applicable

Set column types using json

Hi 🙂 

 

i have a custom power bi connector that loads data from various json sources.
i also have an endpoint that returns the data types for each column in the format

 

{
{
"columnName": "test1",
"columnType": "Number.Type"
},
{
"columnName": "test2",
"columnType": "Number.Type"
}, ...

}

 

I have tried this but always get an error:

ColumnTypeTable = Table.FromRecords(JsonColumnTypeData), //json data to table
ColumnTypeList = Table.ToList(Columns), //table to list
TestTable = Table.TransformColumnTypes(Source, ColumnTypeList )

 

How do i have to transform the columns type list so that i can pass them

 

Thank you so much!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous, @lbendlin,

ColumnTypeTable = Table.FromRecords(JsonColumnTypeData), //json data to table
ColumntypeList = Table.TransformRows(dataTable, each {[columnName], MapColumnType([columnType])}),

 That's how it works for me. I have created a mapping method to map the text type from JSON to Power Query type.

 

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Anonymous, @lbendlin,

ColumnTypeTable = Table.FromRecords(JsonColumnTypeData), //json data to table
ColumntypeList = Table.TransformRows(dataTable, each {[columnName], MapColumnType([columnType])}),

 That's how it works for me. I have created a mapping method to map the text type from JSON to Power Query type.

 

Can you show the code for MapColumnType ?

Anonymous
Not applicable

yes of course 🙂 

 

MapColumn = (columnType as text) as any => 
    let
        MappedType = 
            if (columnType = "Integer") then Int64.Type
            else
            if (columnType = "Text") then Text.Type
            else
            if (columnType = "Number") then Number.Type
            else
            if (columnType = "Date") then Date.Type
            else Text.Type
    in MappedType;

I have changed the type of the service so that is more generic.

Is the solution correct? 🙂

if it works for your scenario then that's all that matters. Setting the alternate to Text makes sense.

Anonymous
Not applicable

Hi @Anonymous ,

Please refer to the following links.

Need help expanding JSON list in column... 

Multi-Dimensional Json file to Table 

 

Best Regards

Community Support Team _ Polly

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

The type names in Power Query are different from what you get in the Json.  For example "Number.Type"  can be anything from "Int64.Type"  to "type number".  And the transform list expects just the column names and transforms, not the additional meta data from your Json.

 

Table.TransformColumnTypes - PowerQuery M | Microsoft Docs

 

Please provide sanitized sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

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.