Forum Discussion

gmachowiak's avatar
gmachowiak
Frequent Visitor
2 years ago
Solved

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...
  • ronrsnfld's avatar
    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