5

I concatenated four columns using this code (to prevent null values to be linked together) in Power Query (Power BI Desktop):

= Text.Combine(List.Select(
{ [Col1], [Col2], [Col3], [Col4]    
}, each _<> "" and _ <> null),"; "))

I was wondering if there is a way to insert a line break instead of the "; " delimiter; that would make my visuals look neater!

Thanks in advance!

DatAlessia
  • 73
  • 1
  • 1
  • 7

3 Answers3

6

Try using "#(lf)" or "#(cr)" in place of "; "

= Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.Select({ [Column1], [Column2], [Column3], [Column4]}, each _<> "" and _ <> null),"#(lf)"))

or

= Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(List.Select({ [Column1], [Column2], [Column3], [Column4]}, each _<> "" and _ <> null),"#(cr)"))

Make sure to format the cells back in Excel as Word Wrap

horseyride
  • 17,007
  • 2
  • 11
  • 22
5

you can use Lines.ToText (https://learn.microsoft.com/en-us/powerquery-m/lines-totext) without the optional lineSeparator.

Dario Oddenino
  • 1,294
  • 2
  • 9
  • 15
2

beside Darios solution I'd like to mention, that there is an additional line break after the last entry.

I fixed it by splitting the column at the first #cr (from the right side) and deleted the #cr-col after that.

MichaelT
  • 71
  • 1
  • 1
  • 7