To insert a new line character in Power Query, you must use the formula #(lf) for a line feed or #(cr)#(lf) for a carriage return and line feed within the formula bar or a custom column expression. This allows you to create multi-line text strings, format reports for better readability, or split columns based on invisible line breaks that occur in raw data imports.

What You'll Need

  • Microsoft Excel or Power BI Desktop.
  • Access to the Power Query Editor (Get Data > Launch Power Query Editor).
  • A dataset containing text columns that require formatting or splitting.

Step-by-Step

Method 1: Inserting a New Line in a Custom Column

Use this method when you want to combine multiple columns into one cell but want each piece of data to appear on a new line.

  1. Open the Power Query Editor window.
  2. Navigate to the Add Column tab on the top ribbon.
  3. Select Custom Column.
  4. In the New column name field, enter a descriptive name (e.g., "Formatted Address").
  5. In the Custom column formula box, write your concatenation formula. For example, if you are combining a City and a State column, enter: . Note that the #(lf) must be inside double quotes.
  6. Click OK.
  7. Important: The preview in the Power Query Editor often shows the text on a single line or displays the literal characters. To see the actual line break, you must load the data into an Excel sheet and enable Wrap Text for those cells.

Method 2: Replacing a Character with a New Line

Use this method when your data has a specific delimiter (like a semicolon or a pipe) that you want to convert into a line break for better presentation.

  1. Select the column containing the text you wish to modify.
  2. Right-click the column header and select Replace Values....
  3. In the Value To Find box, type the character you want to remove (e.g., a semicolon ;).
  4. In the Replace With box, you cannot simply press Enter. Leave this box empty for a moment and click OK. This creates the step in the formula bar.
  5. Look at the formula bar at the top of the screen. You will see a function that looks like: = Table.ReplaceValue(#""Changed Type"",";","",Replacer.ReplaceText,{"Column1"}).
  6. Manually edit the formula in the bar. Replace the empty quotes "" (the replacement value) with "#(lf)".
  7. Press Enter to apply the change.

Method 3: Splitting Columns by New Line Character

If you have imported data where multiple values are crammed into one cell separated by line breaks, you can split them into separate columns.

  1. Select the column you want to split.
  2. Go to the Home tab and select Split Column > By Delimiter.
  3. In the dropdown menu for Select or enter delimiter, choose --Custom--.
  4. Check the box that says Split using special characters.
  5. Click the Insert special character button and select Line Feed (or Carriage Return if applicable). Power Query will automatically insert #(lf) into the delimiter box.
  6. Choose whether to split into Columns or Rows depending on your data structure needs.
  7. Click OK.

Common Mistakes

One of the most frequent errors is attempting to type a physical line break into the Custom Column dialog box by pressing the Enter key. In Power Query, pressing Enter inside the formula box usually confirms the dialog or creates a syntax error; it does not insert a carriage return into the resulting text string. You must use the specific M-code escape sequence #(lf).

Another common mistake is forgetting that Power Query's preview window is not a "What You See Is What You Get" (WYSIWYG) editor. Users often believe the formula failed because the preview still shows the text on one line. The line break is there, but the grid view is designed for data inspection, not final document formatting. If you don't see the break in Excel after loading, it is almost always because the Wrap Text setting is turned off in the Excel Home tab.

Some users confuse #(lf) (Line Feed) with #(cr) (Carriage Return). While they seem identical, different operating systems and software generate different breaks. Windows typically uses a combination of both (CRLF). If you use only #(lf) and the data still looks wrong in a specific legacy application, you may need to use #(cr)#(lf) to ensure compatibility.

Tips

When dealing with large datasets, using Split Column by Delimiter with the Rows option is a powerful way to "unpivot" data that was poorly formatted in the source. Instead of creating 50 new columns for 50 possible line breaks, splitting into rows keeps your table narrow and makes it easier to create Pivot Tables later.

If you find yourself frequently inserting new lines across many different queries, consider creating a custom function. You can write a simple M-function that takes two strings and joins them with a line feed, reducing the amount of manual typing and the risk of typos in your #(lf) syntax.

To verify that your line breaks are working before loading to Excel, you can create a temporary "Check" column using a formula like Text.Contains([ColumnName], "#(lf)"). This will return a TRUE or FALSE value, confirming that the invisible character is present in the data stream.

Troubleshooting

If the line break is not appearing in your final output, follow these steps in order:

  1. Check Wrap Text: In Excel, select the cells, go to the Home tab, and click Wrap Text. Without this, Excel displays the entire string on one line regardless of the characters present.
  2. Verify the Sequence: Ensure you used #(lf) and not #lf or (lf). The hash symbol and parentheses are mandatory.
  3. Check for Double Quotes: Ensure the sequence is wrapped in double quotes: "#(lf)". If you place it outside quotes, Power Query will treat it as a variable name and return an error.
  4. Test CRLF: If you are exporting the data to a CSV or a text file and the breaks aren't recognized by the receiving software, try replacing #(lf) with #(cr)#(lf).
  5. Inspect Source Data: If you are splitting columns and it isn't working, the source might be using a different character (like a Tab or a non-breaking space). Use the Split Column > By Delimiter > Special Characters menu to experiment with different invisible characters.

Frequently Asked Questions

What is the difference between #(lf) and #(cr)?

#(lf) stands for Line Feed (common in Unix/Linux/macOS), while #(cr) stands for Carriage Return (common in older Mac systems). Windows uses both together (CRLF) to signal the end of a line.

Can I use a new line character in a Conditional Column?

The standard Conditional Column GUI does not allow you to enter special characters like #(lf). To achieve this, create the conditional column first, then go to the formula bar and manually insert the #(lf) sequence into the resulting if...then...else statement.

Does the new line character increase the file size?

Technically, yes, as it adds a character to the string, but the impact is negligible. It is far more efficient than creating multiple separate columns for the same data.

Why does the line break look like a small box in some apps?

This happens when the application viewing the data does not support the specific line break character used. Switching from #(lf) to #(cr)#(lf) usually resolves this for Windows-based applications.

How do I remove all new line characters from a column?

Use the Replace Values feature. In the Value To Find box, use the Special Characters menu to select Line Feed, and leave the Replace With box completely empty. This will strip all line breaks and flatten the text into a single line.