Skip to main content

Power BI

Needs Votes

Editing a formula in the formula bar should preserve newlines, not replace with #(lf)

Vote (5) Share
John Doggett's profile image

John Doggett on 21 Nov 2018 09:13:14

Using the Power Query formula bar to edit something like this:

= (_TimelineWithParent as any) => let
Initial = _TimelineWithParent,
#"Add initial pidx" = Table.DuplicateColumn(Initial, "parentIndex", "pidx"),


Might result in:

let
Source = #!"(_TimelineWithParent as any) => let#(lf) Initial = _TimelineWithParent,#(lf) #""Add initial pidx""

That is a heavily escaped string that now only looks right in the formula bar.

Formula bar and Advanced Editor should always agree...

Comments (4)
John Doggett's profile image Profile Picture

Christian Schmidt on 02 Mar 2023 14:39:53

RE: Editing a formula in the formula bar should preserve newlines, not replace with #(lf)

I would prefer preserving newlines and tabs in custom-written sql, too. It's absolutely annoying if you've got to make corrections in a datasource.

John Doggett's profile image Profile Picture

Kieran Leigh on 18 Feb 2022 09:46:49

RE: Editing a formula in the formula bar should preserve newlines, not replace with #(lf)

This happens for me if I paste in a multi-line formula but failed to copy the = at the start. The logic seems to be that it looks like I meant to paste a string, so it tries to correct my input to an escaped string.Most of the automatic corrections make mistakes occasionally, but they're usually simple to fix. This correction is particularly aggressive, so either it should ask permission, or offer a simple way to revert it and let the user correct syntax manually.

John Doggett's profile image Profile Picture

John Doggett on 05 Jul 2020 23:35:37

RE: Editing a formula in the formula bar should preserve newlines, not replace with #(lf)

This seems to happen with formulas that are syntactically incomplete (e.g. extra comma, etc). If the syntax is correct the newlines get restored.

John Doggett's profile image Profile Picture

John Doggett on 05 Jul 2020 23:35:37

RE: Editing a formula in the formula bar should preserve newlines, not replace with #(lf)

Also happens a lot if you try to shift-click the entire contents of a multi-argument function call (text between the parents)