Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

add rows in a blank table with comma separated values from another table

I have a table1 as below and it has around 20k rows. I want to create another table2 where every 3 rows of table1 will be added as comma separated value in one row in table2.

 

Table1

org name      id

test                1

test                2

test                3

test                4

test                5

test                6

 

Table2

org name      id

test              1,2,3

test              4,5,6

  • Anonymous's avatar
    Anonymous
    5 years ago

    This will work:

     

    Custom1 = Table.Split(PriorStepName, 3),
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Org ID", each Table.FirstValue([Column1]), type text),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Values", each [Column1][Index]),
    #"Removed Columns2" = Table.RemoveColumns(#"Added Custom1",{"Column1"}),
    #"Extracted Values" = Table.TransformColumns(#"Removed Columns2", {"Values", each Text.Combine(List.Transform(_, Text.From), ","), type text})
    in
    #"Extracted Values"

     

    --Nate

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    This will work:

     

    Custom1 = Table.Split(PriorStepName, 3),
    #"Converted to Table" = Table.FromList(Custom1, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "Org ID", each Table.FirstValue([Column1]), type text),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Values", each [Column1][Index]),
    #"Removed Columns2" = Table.RemoveColumns(#"Added Custom1",{"Column1"}),
    #"Extracted Values" = Table.TransformColumns(#"Removed Columns2", {"Values", each Text.Combine(List.Transform(_, Text.From), ","), type text})
    in
    #"Extracted Values"

     

    --Nate

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Anonymous  Thanks. you saved the day