Forum Discussion
How to use m code with (Left(Right(.Range to extract data from a cell?
- 5 years ago
Hi Anonymous
Please try this, I've tested it and it works on the string you provided. What makes this tricky is that the last character in the string is not an apostrophe,it's a back tick ` The character under the tilde key which is at the top left of my keyboard.
let Source = Excel.CurrentWorkbook(){[Name="cellA4"]}[Content], Substr = Table.AddColumn(Source, "Substring", each Text.Middle([Column1] , Text.PositionOf([Column1], ":", 1) + 1 , Text.PositionOf([Column1], "`") - Text.PositionOf([Column1], ":", 1) - 1)) in SubstrPhil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Anonymous , you may extract the substring this way,
let
Source = Excel.CurrentWorkbook(){[Name="cellA4"]}[Content],
Added = Table.AddColumn(Source, "SubStr",
each [
positions = Text.PositionOfAny([Column1], {"'", "`"}, Occurrence.All),
substr = Text.Range([Column1], positions{0}+1, positions{1}-positions{0}-1)
][substr]
)
in
Added- Anonymous5 years agoNot applicable
I copy and pasted your code, and the SubStr came almost perfect. However I don't want the "From:", Just the Date string.
Should I replace the:
positions = Text.PositionOfAny([Column1], {"'", "`"}, Occurrence.All),With
positions = Text.PositionOfAny([Column1], {":", "`"}, Occurrence.All),Also, the results in the Custom Column, just say Table..?
- CNENFRNL5 years ago
Community Champion
Anonymous , based on your mockup data, it's easier to change
substr = Text.Range([Column1], positions{0}+1, positions{1}-positions{0}-1)to
substr = Text.Range([Column1], positions{0}+7, positions{1}-positions{0}-1)to get the desired substring.