Forum Discussion

barthhsk's avatar
barthhsk
Frequent Visitor
3 years ago
Solved

Extracting text as string from table in column

Hi,

 

I am struggling with following transformation: 

 

From a column "aanleiding toezicht" I need to expand the tables without adding extra rows. Therefore I planned to create  a string of the list which is inside of the table. The length of this list is varying, however the amount of columns is the same for each table.

 

     

My Table is called Tabel. Below a typical example of the list:

 

The following steps I tried:

result = each if Value.Is(Tabel[aanleiding toezicht],Table.Type) = true
then Text.Combine(Table.ToList(Tabel[aanleiding toezicht]{0}),";")
else Tabel[aanleiding toezicht],
Tabel2 = Table.AddColumn(Tabel,"aanleiding toezicht2", result)

 

Unfortunatly this is resulting in different error messages. My question is, if I am using the right approach?

 

Thank you in advance!

 

 

 

  • Hi barthhsk ,

    please try the following:

    Tabel2 = Table.AddColumn(Tabel,"aanleiding toezicht2", each if Value.Is([aanleiding toezicht], Table.Type) then Text.Combine([aanleiding toezicht][Element:Text],";")
    else Tabel[aanleiding toezicht])

2 Replies

  • ImkeF's avatar
    ImkeF
    Community Champion

    Hi barthhsk ,

    please try the following:

    Tabel2 = Table.AddColumn(Tabel,"aanleiding toezicht2", each if Value.Is([aanleiding toezicht], Table.Type) then Text.Combine([aanleiding toezicht][Element:Text],";")
    else Tabel[aanleiding toezicht])
  • barthhsk's avatar
    barthhsk
    Frequent Visitor

    Hi ImkeF,
    Thank you for your fast reply. I tried your suggestion. With a slight adaptation - because of the not accepted column name - the problem was solved:

    = Table.AddColumn(Tabel,"aanleiding toezicht2", each if Value.Is([aanleiding toezicht], Table.Type) then Text.Combine({[aanleiding toezicht][#"Element:Text"]},";")
    else [aanleiding toezicht])

    Combined with:

    = Table.TransformColumns(Aangepast3, {{"aanleiding toezicht2", each if Value.Is(_,type list) = true 
    then Text.Combine(List.Transform(_, Text.From), ";") else _}})