Forum Discussion
Is there a way to explicitly change a column type in Power Query?
- 2 years ago
to create table you want with #table
let tableA = #table( type table [Test = Int64.Type], { {1 as number}, {"2" as text} } ) in tableAto 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."