How can I expand all lists in a row of lists at the same time?

安稳与你 提交于 2019-12-13 18:20:57

问题


I would like to expand all of the lists in this table at once without having to explicitly name (hard-code) each column. I do want to assume that all columns have a list in the row. I also want to be able to apply the solution to a table with less or more columns than are in the example. The table might decrease or increase its number of columns and the columns' names might change, which is why I don't want to use explicit column names.

I've found a few threads about expanding multiple lists at once, at various forum sites, but they all address more than just doing what I describe above and have all confused me to one degree or another as I've tried to fit them to my need.

@MarcelBeug provides a detailed solution at this site (as do other folks too). I'm using @MarcelBeug's function, and it works great; but I'd like to tailor it to just what I'm seeking, as mentioned above, and I'm having trouble doing that.

So how do I do this?


回答1:


You want to aggregate the Table.ExpandListColumn function across each column:

let
    Source = #table({"A", "B"}, {{ {1,2}, {3,4}} }),
    Expanded = List.Accumulate(
        Table.ColumnNames(Source), 
        Source, 
        (state, column) => Table.ExpandListColumn(state, column))
in
    Expanded


来源:https://stackoverflow.com/questions/44418244/how-can-i-expand-all-lists-in-a-row-of-lists-at-the-same-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!