源
= Table.FromRecords(
{
[姓名 = "A", 成绩 = 1],
[姓名 = "B", 成绩 = {2, 3}],
[姓名 = "C", 成绩 = {{15, 4}, 5}],
[姓名 = "D", 成绩 = {6, {7, 8}, {9, {10, 11, 12}, 13}, 14}]
}
)
我想一步展开table,应该是为了学习递归自己编造的数据,但是不会做,卡壳了好多天了。请各位不吝赐教
已经解决了
let
源 = Table.FromRecords(
{
[姓名="A",成绩=1],
[姓名="B",成绩={2,3}],
[姓名="C",成绩={{15,4},5}],
[姓名="D",成绩={6,{7,8},{9,{10,11,12},13},14}]
}
),
fx=(a)=> List.Accumulate(a,{},
(x,y)=>
if y is number
then x&{y}
else x&@fx(y)
),
遍历成绩 = Table.TransformColumns(源,{"成绩",each if _ is number then _ else fx(_)}),
展开的 = Table.ExpandListColumn(Table.SelectRows(遍历成绩, each [成绩] is list), "成绩")&Table.SelectRows(遍历成绩, each [成绩] is number)
in
展开的