Power Query - Delete First Line Feed (#lf)

Caleeco

Well-known Member
Joined
Jan 9, 2016
Messages
980
Office Version
  1. 2010
Platform
  1. Windows
Hello

I’ve done some googling but come up blank! I have a Power Query where I replace all instances of ‘*’ with a #(lf).

However, all my rows now have a leading line feed. Is it possible to delete just the first instance of the line feed and leave the others in place?

Cheers
Caleeco
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
if I understand well, try Table.Skip(Source,1)
or show example of you table
 
Upvote 0
Hi Sandy,
Thanks for the reply. Apologies if my question wasn’t clear. Clarification:
  • I don’t want to skip an entire record
  • Each record has a column with a text field
  • In each text entry (on each record). There is a leading #(LF) line feed in the text
  • I want to delete said line feed but leave all others in the same record intact
 
Upvote 0
you can try
Table.ReplaceValue
eg. Table.ReplaceValue([I]previous_step[/I]," #(lf) blabla bla blabla","blabla bla blabla",Replacer.ReplaceText,{"[I]column_where_is_value_to_replace[/I]"})
if not, post representative example of source data and expected result from this source
 
Last edited:
Upvote 0
Hi Sandy,

Thanks for sticking with me. Example below

Step StepResultant Text
1Import Data* Product ID * Product Name * Signature
2Replace all instances of '* ' with '#(lf)'#(lf)Product ID #(lf)Product Name #(lf)Signature
3Current Output in one cell in Excel(blank line)
Product ID
Product Name
Signature


So you see when I export to excel, and wrap text the first Line Feed creates a blank line of text in the cell. So I would like to add a step after Step 2, to remove only the first line feed in the string.

Is this possible?

Kind Regards
Caleeco
 
Upvote 0
like this?

lf.png

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    TrimStart = Table.AddColumn(Source, "Custom", each Text.TrimStart([Import],"*")),
    Trim = Table.TransformColumns(TrimStart,{{"Custom", Text.Trim, type text}}),
    Replace = Table.ReplaceValue(Trim,"*","#(lf)",Replacer.ReplaceText,{"Custom"}),
    TSC = Table.SelectColumns(Replace,{"Custom"})
in
TSC
 
Upvote 0
Yes! That's what I was after

Thank you for the M code, I will test this when I'm at work tomorrow and let you know how i get on!

Cheers
Caleeco
 
Upvote 0
You are welcome
I think first what you should do is replace space*space to* because of the spaces in front of second and third line
so it will like this
lf.png

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
    Rep = Table.ReplaceValue(Source," * ","*",Replacer.ReplaceText,{"Import"}),
    TrimStart = Table.AddColumn(Rep, "Custom", each Text.TrimStart([Import],"*")),
    Trim = Table.TransformColumns(TrimStart,{{"Custom", Text.Trim, type text}}),
    Replace = Table.ReplaceValue(Trim,"*","#(lf)",Replacer.ReplaceText,{"Custom"}),
    TSC = Table.SelectColumns(Replace,{"Custom"})
in
    TSC
 
Upvote 0
Hi Sandy,

Just tested this at work and it's perfect! Thank your help, you saved me a lot of time & headache! haha

Cheers
Caleeco
 
Upvote 0

Forum statistics

Threads
1,223,790
Messages
6,174,600
Members
452,574
Latest member
hang_and_bang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top