Forum Discussion
renee_crozier
Oct 25, 2024Brass Contributor
XLOOKUP Not Finding Associated Value After Cleaning Up Data With Power Query
I am trying to find a file that is associated with a link using XLOOKUP. In the source document I am using, the links have hex characters in the URL and the file name listed in the report does not. I...
SergeiBaklan
Oct 26, 2024Diamond Contributor
As a comment, not to replace UTF-8 codes one by one, you may take encoding table from here HTML URL Encoding Reference using Power Query
let
Source = Web.BrowserContents("https://www.w3schools.com/tags/ref_urlencode.asp?bcsi-ac-4d57fec82d0c41f9=271918E500000005GWA6BeQ6JifHv9+eq2S/b7a4YSJMAAAABQAAAHXHRgCAcAAAAAAAAAGYAAA="),
ExtractTable = Html.Table(
Source,
{
{"Column1", "TABLE.ws-table-all.notranslate:nth-child(36) > * > TR > :nth-child(1)"}
, {"Column2", "TABLE.ws-table-all.notranslate:nth-child(36) > * > TR > :nth-child(2)"}
, {"Column3", "TABLE.ws-table-all.notranslate:nth-child(36) > * > TR > :nth-child(3)"}
}, [RowSelector="TABLE.ws-table-all.notranslate:nth-child(36) > * > TR"]
),
PromotHeaders = Table.PromoteHeaders(
ExtractTable,
[PromoteAllScalars=true]),
SelectColumns = Table.SelectColumns(
PromotHeaders,
{"From UTF-8", "Character"}),
ReplaceSpace = Table.ReplaceValue(
SelectColumns,
"space",
" ",
Replacer.ReplaceText,{"Character"}),
ReplaceEmptyOnSpace = Table.ReplaceValue(
ReplaceSpace,
"",
" ",
Replacer.ReplaceValue,{"Character"}),
RenameColumns = Table.RenameColumns(
ReplaceEmptyOnSpace,
{{"From UTF-8", "UTF-8"}})
in
RenameColumns
or by any other way. Having such table replacements could be done as
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
ListReplacmentsTexts = List.Zip(
{
#"ASCII Encoding Reference"[#"UTF-8"],
#"ASCII Encoding Reference"[Character]
}
),
ReplaceTexts = Table.TransformColumns(
Source,
{
{"LinkURL",
each List.Accumulate(ListReplacmentsTexts,_,(x,y)=>Text.Replace(x,y{0},y{1})),type text}
}
)
in
ReplaceTexts
Please check in attached file.