Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Suppose I create a table:
let
tableA = #table(
{"Test"},
{
{1 as number},
{"2" as text}
}
)
in
tableA
Then I check the column type of "Test" with Table.Schema() and see that the "Test" column type is any.
tableASchema = Table.Schema(tableA)
Is there a way to change the column type to number ?
I expect the following output:
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.
Solved! Go to Solution.
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.
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:
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 19 | |
| 9 | |
| 8 | |
| 7 | |
| 6 |