Reputation: 83
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!
Upvotes: 6
Views: 30526
Reputation: 81
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.
Upvotes: 2
Reputation: 21373
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
Upvotes: 6
Reputation: 1304
you can use Lines.ToText (https://learn.microsoft.com/en-us/powerquery-m/lines-totext) without the optional lineSeparator.
Upvotes: 5