Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Split multiple columns into rows at once

I have a table that has 37 columns. each column needs to be split in to rows. If I did that to one by one it is a big mess. I need a code to apply to make it all at once. Here is a sample of the table

I need to see it as

index    Programming languages    Integrated development environments etc..

1          python                                   jupyter

1           null                                        Rstudio

10        R                                            Rstudio

10        SQL                                        Vm/Emacs

10        Juilia                                      null

10        Bash                                        null

 

I have tried this code:

= List.Accumulate(
Table.ColumnNames(Source),
Source,
(st, cur) =>
if List.AnyTrue(List.Transform(Table.Column(st, cur), each Text.Contains(_, ";")))
then Table.SplitColumn(st, cur, Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), 6)
else st
)

But it split them in to columns not rows 

I need help as soon as possible 

  • Anonymous's avatar
    Anonymous
    5 years ago

    Based on the proposed example, this script should do what is required.
    An implicit assumption, for example, is that indexes are unique.
    If something does not work as desired, explain well what by loading the tables (so that they can be copied, not as images) on which it does not work and indicating exactly the error and where it occurs.

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Based on the proposed example, this script should do what is required.
    An implicit assumption, for example, is that indexes are unique.
    If something does not work as desired, explain well what by loading the tables (so that they can be copied, not as images) on which it does not work and indicating exactly the error and where it occurs.

    • Anonymous's avatar
      Anonymous
      Not applicable

      This is amazing! it worked like a charm.

      I had to replace nulls first to get it working

      = Table.TransformColumns(Source,{},(x) => Replacer.ReplaceValue(x,null,""))

      but overall it worked out very well

      Thank you very much