Table.ExpandTableColumn

Syntax

Table.ExpandTableColumn(
    table as table,
    column as text,
    columnNames as list,
    optional newColumnNames as nullable list
) as table

About

将 [table] 中的column表扩展到多个行和列中。 columnNames 用于选择要从内部表展开的列。 指定 newColumnNames 以避免现有列和新列之间的冲突。

请注意,除了嵌套表,该函数还支持扩展嵌套的记录列表。

示例

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

用法

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

输出

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