Forum Discussion
RecycleBin_Rob
Oct 09, 2024Copper Contributor
Extract Address from Cell Text
Background: I'm working with address data that uses the quadrant system (ends with NW, NE, SW, or SE). There are only very few instances where it ends with N or S. I have a column of data that...
SergeiBaklan
Oct 10, 2024Diamond Contributor
Updated a bit
as
let
Source = Excel.CurrentWorkbook(){[Name="source"]}[Content],
quadrants = {" NW", " NE", " SW", " SE", " N", " E", " S", " W"},
fn = (str as text, add as text) =>
[
position = List.Max(
List.Transform(
quadrants,
(q) => [ p=Text.PositionOf(
str,
q & add,
Occurrence.Last,
Comparer.OrdinalIgnoreCase
),
e = if p < 0 then p else p + Text.Length(q)
][e]
)
),
length = if position < 0
then Text.Length(str)
else position
][length],
GetAddress = Table.AddColumn(
Source,
"Address",
each [
sepMid = fn([Text], " "),
sep = fn([Text], "" ),
sepEnd = List.Min({ sepMid, sep }),
address = Text.Start( [Text], sepEnd)
][address]
)
in
GetAddress
- RecycleBin_RobOct 11, 2024Copper ContributorThanks so much for making the adjustments! Next time I will know to provide more dummy data to help illustrate my cases. I'm still developing my Power BI skills so I'm hoping you can offer some more guidance to a rookie when using this formula.
The Excel file isn't actually the source data and allowed me an easier way to see the data as of right now.
Source: Oracle
Navigation: SYNERGY{[Name="WORK_ORDER"]}
Column (with address): [WORK_DESC]
I am not strong at querying and am mistyping something that is leading to errors:
Source = Oracle.Database("Oracle",SYNERGY{[Name="WORK_ORDER"]}[WORK_DESC]),
Any further assistance is greatly appreciated, and if you need more information, please let me know.- peiyezhuOct 11, 2024Bronze Contributorhttps://www.oracletutorial.com/oracle-string-functions/oracle-regexp_like/
oracle support regular expression.
You can try it- SergeiBaklanOct 12, 2024Diamond Contributor
Could you suggest regex pattern for such case?
- SergeiBaklanOct 11, 2024Diamond Contributor
Sorry, I have no experience with Oracle. Just in case, here Power Query Oracle database connector - Power Query | Microsoft Learn is how to configure connection.
- RecycleBin_RobOct 11, 2024Copper Contributor
Hi, Thanks, I'll set up the Oracle at a later date. Ideally, I can get the Excel working first. I'm still running into a few issues.
I added a new Custom Column (Address) and inserted the coding you provided to my Excel sheet.
When I click on expand (in the column header), I get an error.
When I click on table and try to expand the address, I get an error.
Anymore insight you can provide? Thanks!