Table.ExpandListColumn

Syntax

Table.ExpandListColumn(table as table, column as text) as table

About

给定一个 table 包含值列表的位置 column ,将列表拆分为每个值的行。 其他列中的值在创建的每个新行中重复。 此函数还可以通过将嵌套表视为记录列表来扩展嵌套表。

示例 1

拆分列表列 [Name]。

用法

Table.ExpandListColumn(
    Table.FromRecords({[Name = {"Bob", "Jim", "Paul"}, Discount = .15]}),
    "Name"
)

输出

Table.FromRecords({
    [Name = "Bob", Discount = 0.15],
    [Name = "Jim", Discount = 0.15],
    [Name = "Paul", Discount = 0.15]
})

示例 2

拆分嵌套表列 [Components]。

用法

Table.ExpandListColumn(
    #table(
        {"Part", "Components"},
        {
            {"Tool", #table({"Name", "Quantity"}, {{"Thingamajig", 2}, {"Widget", 3}})}
        }
    ),
    "Components"
)

输出

Table.FromRecords({
    [Part = "Tool", Components = [Name = "Thingamajig", Quantity = 2]],
    [Part = "Tool", Components = [Name = "Widget", Quantity = 3]]
})