Forum Discussion
gmachowiak
2 years agoFrequent Visitor
Create Table from nested tables containing one column each
Hi, I've got a working solution for my problem but it seems a bit excessive/overkill. What i have is a table with two columns: LP, ColumnValues; :: Column LP contains column names :: ColumnVal...
- 2 years ago
Try this:
let //define table Source = #table( { "LP","ColumnValues" }, { {"Co1",#table({"Col1"},{{1},{2},{3}})}, {"Co2",#table({"Col2"},{{10},{20},{30}})}, {"Co3",#table({"Col3"},{{100},{200},{300}})} } ), Columns = List.Accumulate( Source[ColumnValues], {}, (s,c)=> s & Table.ToColumns(c)), Result = Table.FromColumns(Columns, Source[LP]) in Result
ronrsnfld
2 years agoSuper User
Try this:
let
//define table
Source =
#table(
{
"LP","ColumnValues"
},
{
{"Co1",#table({"Col1"},{{1},{2},{3}})},
{"Co2",#table({"Col2"},{{10},{20},{30}})},
{"Co3",#table({"Col3"},{{100},{200},{300}})}
}
),
Columns = List.Accumulate(
Source[ColumnValues],
{},
(s,c)=> s & Table.ToColumns(c)),
Result = Table.FromColumns(Columns, Source[LP])
in
Result