Lines.FromText is a Power Query M function that converts a text value to a list of text values split at line breaks. The function returns a list of text values with or without line break characters based on the includeLineSeparators parameter.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Lines.FromText(
text as text,
optional quoteStyle as nullable number,
optional includeLineSeparators as nullable logical,
) as list
Argument | Attribute | Description |
---|---|---|
Text | This is the text value to convert. | |
quoteStyle | Optional | You can provide a QuoteStyle Type that instructs how to deal with double quote characters. You can choose from QuoteStyle.None or QuoteStyle.Csv. |
includeLineSeparators | Optional | Instructs Power Query whether to return line separators in the result. You can either provide the value true or false . Power Query defaults to false when omitting this argument. |
Description
Converts a text value to a list of text values split at lines breaks. If includeLineSeparators is true, then the line break characters are included in the text.
Examples
The Lines.FromText function splits a text value by line feed, also known as line separator.
// Returns { "a", "b", "c", "d" }
= Lines.FromText(
"a
b
c
d"
)
// This is identical to:
= Lines.FromText( "a#(lf)b#(lf)c#(lf)d" )
You can provide a QuoteStyle Type to indicate how to interpret double quotes in a string. You can choose from QuoteStyle.None or QuoteStyle.Csv.
// Results in a single item in a list, including a linebreak
// Returns: { "This is a ""string,#(lf)string""" }
= Lines.FromText(
"This is a ""string,
in quotes""",
QuoteStyle.Csv )
// Results in a 2 items list
// Returns: { "This is a ""string,", "string""" }
= Lines.FromText(
"This is a ""string,
in quotes""",
QuoteStyle.None )
The includeLineSeparators argument instructs Power Query whether to return line separators in the result. Specifying true will return line separators, represented by #(lf). When providing false (or omitting the argument), the line-separators are used to split the string but are not returned in the result. Have a look at the following example:
// Returns { "a#(lf)", "b#(lf)", "c#(lf)", "d#(lf)" }
= Lines.FromText(
"a#(lf)b#(lf)c#(lf)d",
QuoteStyle.Csv,
true
)
// Returns { "a", "b", "c", "d" }
= Lines.FromText(
"a#(lf)b#(lf)c#(lf)d#(lf)",
QuoteStyle.Csv,
false
)
Related functions
Other functions related to Lines.FromText are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy