Table.ExpandRecordColumn

Syntax

Table.ExpandRecordColumn(
    table as table,
    column as text,
    fieldNames as list,
    optional newColumnNames as nullable list
) as table

About

column给定输入table中的记录,为记录中的每个字段创建一个具有列的表。 (可选) newColumnNames 可以指定,以确保新表中的列的唯一名称。

  • table:要展开的记录列的原始表。
  • column:要展开的列。
  • fieldNames:要扩展到表中列的字段列表。
  • newColumnNames:要为新列提供列的列名列表。 新列名不能复制新表中的任何列。

示例

将“位置”列展开为两个新列。

用法

Table.ExpandRecordColumn(
    Table.FromRecords({
        [
            Company = "Contoso",
            Location = [City = "Redmond", State = "WA"]
        ],
        [
            Company = "Fabrikam",
            Location = [City = "Tempe", State = "AZ"]
        ]
    }),
    "Location",
    {"City", "State"},
    {"Location.City", "Location.State"}
)

输出

Table.FromRecords({
    [Company = "Contoso", Location.City = "Redmond", Location.State = "WA"],
    [Company = "Fabrikam", Location.City = "Tempe", Location.State = "AZ"]
})