Table.ExpandTableColumn

語法

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

關於

將 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"]
})