Table.TransformColumnTypes
構文
Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as table
について
省略可能なカルチャを使用して、指定した列に変換操作を適用してテーブルを返します。
table
: 変換する入力テーブル。typeTransformations
: 適用する型変換。 1 つの変換の形式は{列名、型値}です。 変換の一覧を使用して、一度に複数の列の型を変更できます。 列が存在しない場合は、エラーが発生します。culture
: (省略可能) 列の型を変換するときに使用するカルチャ ("en-US"など)。
typeTransformations
パラメーターの型値は、any
、すべての number
型、text
、すべての date
、time
、datetime
、datetimezone
、および duration
型、logical
、または binary
にすることができます。 このパラメーターでは、list
、record
、table
、または function
の型は無効です。
例 1
最初の列の数値をテキスト値に変換します。
使用
let
Source = #table(type table [a = number, b = number],
{
{1, 2},
{3, 4}
}),
#"Transform Column" = Table.TransformColumnTypes(
Source,
{"a", type text}
)
in
#"Transform Column"
出力
#table(type table [a = text, b = number],
{
{"1", 2},
{"3", 4}
})
例 2
テーブル内の日付をフランス語のテキストに変換します。
使用
let
Source = #table(type table [Company ID = text, Country = text, Date = date],
{
{"JS-464", "USA", #date(2024, 3, 24)},
{"LT-331", "France", #date(2024, 10, 5)},
{"XE-100", "USA", #date(2024, 5, 21)},
{"RT-430", "Germany", #date(2024, 1,18)},
{"LS-005", "France", #date(2023, 12, 31)},
{"UW-220", "Germany", #date(2024, 2, 25)}
}),
#"Transform Column" = Table.TransformColumnTypes(
Source,
{"Date", type text},
"fr-FR"
)
in
#"Transform Column"
出力
#table(type table [Company ID = text, Country = text, Date = text],
{
{"JS-464", "USA", "24/03/2024"},
{"LT-331", "France", "05/10/2024"},
{"XE-100", "USA", "21/05/2024"},
{"RT-430", "Germany", "18/01/2024"},
{"LS-005", "France", "31/12/2023"},
{"UW-220", "Germany", "25/02/2024"}
})
例 3
テーブル内の日付をドイツ語のテキストに変換し、テーブル内の値をパーセンテージに変換します。
使用
let
Source = #table(type table [Date = date, Customer ID = text, Value = number],
{
{#date(2024, 3, 12), "134282", .24368},
{#date(2024, 5, 30), "44343", .03556},
{#date(2023, 12, 14), "22", .3834}
}),
#"Transform Columns" = Table.TransformColumnTypes(
Source,
{{"Date", type text}, {"Value", Percentage.Type}},
"de-DE")
in
#"Transform Columns"
出力
#table(type table [Date = text, Customer ID = text, Value = Percentage.Type],
{
{"12.03.2024", "134282", .24368},
{"30.05.2024", "44343", .03556},
{"14.12.2023", "22", .3834}
})