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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
WanderingBI
Resolver III
Resolver III

Is there a way to explicitly change a column type in Power Query?

Suppose I create a table:

 

 

 

let
  tableA = #table(
    {"Test"}, 
    {
      {1 as number}, 
      {"2" as text}
    }
  )
in
  tableA

 

 

 

 

Ibanez2000_1-1718772319541.png

 

Then I check the column type of "Test" with Table.Schema() and see that the "Test" column type is any.

 

 

 

tableASchema = Table.Schema(tableA)

 

 

 

 

Ibanez2000_2-1718772442902.png

 

Is there a way to change the column type to number ?

 

I expect the following output:

Ibanez2000_4-1718772740952.png

 

If this is not possible, is there a some language architecture background to why this is so? What leads a column type to be set?

To clarify, I do not want to convert the original data types of the values in the column. I want to change the column type directly to impose that the values in the column must conform to the data type of the column.

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

to create table you want with #table 

 

let
  tableA = #table(
    type table [Test = Int64.Type], 
    {
      {1 as number}, 
      {"2" as text}
    }
  )
in
  tableA

 

to change type of existing table 

 

Value.ReplaceType(tableA, type table [Test = Int64.Type])

 

background: read Ben Gribaudo's PQ M Primer, type system part. 

View solution in original post

3 REPLIES 3
AlienSx
Super User
Super User

to create table you want with #table 

 

let
  tableA = #table(
    type table [Test = Int64.Type], 
    {
      {1 as number}, 
      {"2" as text}
    }
  )
in
  tableA

 

to change type of existing table 

 

Value.ReplaceType(tableA, type table [Test = Int64.Type])

 

background: read Ben Gribaudo's PQ M Primer, type system part. 

A bit peculiar is the output that I actually get from this:

Ibanez2000_0-1718778029970.png

The value in row 1 is actually "1" of type text. The Power Query GUI shows it left-aligned as it is a text. The value does not conform to the column type of number, however no error is thrown.

 

This is coherent with the explanation from the link you posted:

"However, the values in the column will still be of type number; “whole number” (technically, Int64) is just a claim, not a true data type from the mashup engine’s perspective."

Thank you so much, that was exactly what I was looking for. The background link is also very valuable.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.