动态取消激活列表中的每一列,powerquery

动态取消激活列表中的每一列,powerquery,powerquery,Powerquery,我正在尝试动态取消列表中提供的每一列的IVOT (Table as table, ColumnNameList as list) as table => List.Accumulate( List.Zip(ColumnNameList, {1..List.Count(ColumnNameList)}), Table, (state, column) => Table.Unpivot(state, column{0}, "

我正在尝试动态取消列表中提供的每一列的IVOT

(Table as table, ColumnNameList as list) as table =>
    List.Accumulate(
        List.Zip(ColumnNameList, {1..List.Count(ColumnNameList)}),
        Table,
        (state, column) => Table.Unpivot(state, column{0}, "Option" & column{1} & "Name", "Option" & column{1} & "Value")
    )

但是,这段代码不起作用,我该怎么做呢?

我最终创建了一个函数来提供唯一的列名,这有点像power query可视化编辑器在现有列已经有列名的情况下自动创建名称

但是,当你通过多个同名项目时,你还无法测试它是如何工作的

(Table as table, ColumnName as text) =>
    if Table.HasColumns(Table, ColumnName) then
        let
            NewName =
                if Text.At(ColumnName, 3) <> "." then
                    ColumnName & ".01"
                else
                    Text.Start(
                        ColumnName,
                        Text.Length(ColumnName) - 2
                    )
                    & Text.PadStart(
                        Text.From(
                            Number.FromText(Text.End(ColumnName, 2))
                            + 1
                        ),
                        2,
                        "0"
                    )
        in
            @FnTableNewColumnName(Table, NewName)
    else
        ColumnName

在调用此函数时,您能给出一个预期前后的示例吗?
(Table as table, ColumnNameList as list) as table =>
    List.Accumulate(
        ColumnNameList,
        Table,
        (state, column) =>
            Table.Unpivot(
                state,
                { column },
                FnTableNewColumnName(state, "attribute"),
                FnTableNewColumnName(state, "value")
            )
    )