Dynamically expand ALL lists and records from json

前端 未结 2 1561
傲寒
傲寒 2021-01-15 00:19

I want to expand all lists and records in a json response. Columns are like e.g. (this is dynamically, it also can be 10 records and 5 lists):

Text, Text, [List], [L

相关标签:
2条回答
  • 2021-01-15 00:33

    Assuming that the previous step in M was named Removed Other Columns, and that the column to expand is named Data, then I replace the line with #"Expanded Data" with the following code:

    #"Expanded Data" =Table.ExpandTableColumn(#"Removed Other Columns", "Data", List.Union(List.Transform(#"Removed Other Columns"[Data], each Table.ColumnNames(_))))
    

    It dynamically adapt to any column names.

    0 讨论(0)
  • 2021-01-15 00:44

    Chris Webb wrote a function to do this for Table-type columns:

    http://blog.crossjoin.co.uk/2014/05/21/expanding-all-columns-in-a-table-in-power-query/

    I've shared a tweaked version of that that I made for Record-type columns:

    https://gist.github.com/Mike-Honey/0a252edf66c3c486b69b

    0 讨论(0)
提交回复
热议问题