Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
SCC1991
New Member

Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

Hi guys

 

I am receiving the following error when invoking a custom function:

 

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

 

We have the following Custom Function:

 

let
Query2 = (Vardate as text)=>
let
Source = Web.BrowserContents("https://www.xe.com/currencytables/?from=USD&date=",[RelativePath=[Vardate]]),
#"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(1)"}, {"Column2", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(2)"}, {"Column3", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(3)"}, {"Column4", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(4)"}}, [RowSelector="TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR"]),
#"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Currency", type text}, {"Name", type text}, {"Units per USD", type number}, {"USD per unit", type number}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Currency", "Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼"}, {"Name", "Currency name#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼"}, {"USD per unit", "USD per Unit"}})
in
#"Renamed Columns"
in
Query2

 

Which is then invoked into the following Query:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W0jVSio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Offset = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Offset", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Date", each Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-2),"yyyy-MM-dd")),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Date", type text}}),
#"Invoked Custom Function1" = Table.AddColumn(#"Changed Type1", "currency_conversion", each #"XE Date"([Date])),
#"Expanded currency_conversion" = Table.ExpandTableColumn(#"Invoked Custom Function1", "currency_conversion", {"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", "Currency name#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", "Units per USD", "USD per Unit"}, {"Currency code#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", "Currency name#(lf)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)#(tab)▲▼", "Units per USD", "USD per Unit"}),
#"Removed Columns" = Table.RemoveColumns(#"Expanded currency_conversion",{"Offset", "Date"}),
#"Changed Type2" = Table.TransformColumnTypes(#"Removed Columns",{{"Units per USD", type number}, {"USD per Unit", type number}})
in
#"Changed Type2"

 

---

 

Would anyone be able to assist?

 

Thanks

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @SCC1991 ,

 

Try this:

 

let
Query2 = (Vardate as text)=>
let
    Source = Web.Contents("https://www.xe.com/currencytables/",[Query = [from="USD", date="2021-04-20"]]),
    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(1)"}, {"Column2", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(2)"}, {"Column3", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(3)"}, {"Column4", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(4)"}}, [RowSelector="TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR"]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Currency", type text}, {"Name", type text}, {"Units per USD", type number}, {"USD per unit", type number}})
in
    #"Changed Type"
in
Query2

 

query2.gif

 

And it can set scheduled refresh.

query2 refresh.PNG

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Icey
Community Support
Community Support

Hi @SCC1991 ,

 

Try this:

 

let
Query2 = (Vardate as text)=>
let
    Source = Web.Contents("https://www.xe.com/currencytables/",[Query = [from="USD", date="2021-04-20"]]),
    #"Extracted Table From Html" = Html.Table(Source, {{"Column1", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(1)"}, {"Column2", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(2)"}, {"Column3", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(3)"}, {"Column4", "TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR > :nth-child(4)"}}, [RowSelector="TABLE.currencytables__Table-xlq26m-3.jaGdii > * > TR"]),
    #"Promoted Headers" = Table.PromoteHeaders(#"Extracted Table From Html", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Currency", type text}, {"Name", type text}, {"Units per USD", type number}, {"USD per unit", type number}})
in
    #"Changed Type"
in
Query2

 

query2.gif

 

And it can set scheduled refresh.

query2 refresh.PNG

 

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

How bout:

Source = Web.BrowserContents("https://www.xe.com/currencytables/?from=USD&date="&Vardate),

 

 

I tried that route originally, it works yes, but it prevents Dynamic Refresh's from happening, which is why we went down the invoke custom function in the first place.

SCC1991
New Member

Hi

 

I did try this, and have tried this again now - I receive this error now:

 

DataSource.Error: Web.BrowserContents: This function doesn't support the query option 'RelativePath' with value '"2021-04-18"'.
Details:
2021-04-18

 

Thanks,

Anonymous
Not applicable

It's should be written in your query as [RelativePath = VarDate] (VarDate is a text variable, and doesn't need to be enclosed in [ ]
--Nate

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.