Is there a way to add line breaks in a string of text in M (Power BI)?
Asked Answered
L

3

6

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!

Laise answered 18/9, 2020 at 16:13 Comment(0)
A
5

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

Anastigmatic answered 18/9, 2020 at 16:37 Comment(0)
S
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

Savaii answered 18/9, 2020 at 17:11 Comment(0)
A
5

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

Anastigmatic answered 18/9, 2020 at 16:37 Comment(0)
H
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.

Humeral answered 24/1, 2023 at 23:33 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.