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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Bmejia
Super User
Super User

Web Source not pulling

Hi,
I am having issues extracting the last line from a web source table.   The last line is the current date exchange date.  When you copy the URL below it will give you the data, that I am pulling without the current date.  The only way to see the current date online is to click on "Retrived Data" which is the same URL below.
 
I feel that I might need to do something to my code that will allow me to click on "Retrive data" prior to pulling the data

I have tried changing the web.browsercontents to web.contents and make sure that I am authenticated correctly in the report and browser. I have used this links for years and never had this issues so I assume the web provider changed something at their end as well.
 
See attachment

https://www.ofx.com/en-ie/forex-news/historical-exchange-rates/cad/usd/

What is capturing:
Bmejia_0-1759855701437.png
 
What I need it to capture:  Only shows when I click on "Retrive Data"
Bmejia_0-1759856240083.png

 

1 ACCEPTED SOLUTION
Aala_Ali
Continued Contributor
Continued Contributor

If I understand you right your Problem is that
OFX shows the latest row only after you click “Retrieve data” (client-side). Power Query can’t click it.

So you can try this :
Fix 1 (quick, no code change)

Use the US locale page that renders the latest daily rows in static HTML:

https://www.ofx.com/en-us/forex-news/historical-exchange-rates/cad/usd/

Get Data → Web → pick the table → keep Date/Rate → sort Date desc → keep top 1.
(Verify direction: USDCAD vs CADUSD; invert if needed.)

Fix 2 (recommended, stable API) – Bank of Canada
Pull the official USDCAD rate and invert to CAD→USD. Paste this M in a blank query:

let

  StartDate   = Date.ToText(Date.AddDays(Date.From(DateTimeZone.FixedUtcNow()), -15), "yyyy-MM-dd"),

  Url         = "https://www.bankofcanada.ca/valet/observations/FXUSDCAD/json?start_date=" & StartDate,

  Clean =

    let

      Source = Json.Document(Web.Contents(Url)),

      T0 = Table.FromList(Source[observations], Splitter.SplitByNothing(), {"obs"}),

      T1 = Table.ExpandRecordColumn(T0, "obs", {"d","FXUSDCAD"}, {"Date","FXUSDCAD"}),

      T2 = Table.ExpandRecordColumn(T1, "FXUSDCAD", {"v"}, {"USDCAD"}),

      T3 = Table.TransformColumnTypes(Table.SelectRows(T2, each ([USDCAD] <> null)),

                                      {{"Date", type date}, {"USDCAD", type number}})

    in

      T3,

  Last = Table.FirstN(Table.Sort(Clean, {{"Date", Order.Descending}}), 1),

  Result = Table.AddColumn(Last, "CADUSD", each 1/[USDCAD], type number)

in

  Result

This returns the latest business day with both USDCAD and CADUSD.

Tip (single value)
If you need just the last value in a measure:

= Rates_Last[CADUSD]{0}

If this helps, please mark as Accepted Solution and drop a 👍"Kudos"

View solution in original post

2 REPLIES 2
Aala_Ali
Continued Contributor
Continued Contributor

If I understand you right your Problem is that
OFX shows the latest row only after you click “Retrieve data” (client-side). Power Query can’t click it.

So you can try this :
Fix 1 (quick, no code change)

Use the US locale page that renders the latest daily rows in static HTML:

https://www.ofx.com/en-us/forex-news/historical-exchange-rates/cad/usd/

Get Data → Web → pick the table → keep Date/Rate → sort Date desc → keep top 1.
(Verify direction: USDCAD vs CADUSD; invert if needed.)

Fix 2 (recommended, stable API) – Bank of Canada
Pull the official USDCAD rate and invert to CAD→USD. Paste this M in a blank query:

let

  StartDate   = Date.ToText(Date.AddDays(Date.From(DateTimeZone.FixedUtcNow()), -15), "yyyy-MM-dd"),

  Url         = "https://www.bankofcanada.ca/valet/observations/FXUSDCAD/json?start_date=" & StartDate,

  Clean =

    let

      Source = Json.Document(Web.Contents(Url)),

      T0 = Table.FromList(Source[observations], Splitter.SplitByNothing(), {"obs"}),

      T1 = Table.ExpandRecordColumn(T0, "obs", {"d","FXUSDCAD"}, {"Date","FXUSDCAD"}),

      T2 = Table.ExpandRecordColumn(T1, "FXUSDCAD", {"v"}, {"USDCAD"}),

      T3 = Table.TransformColumnTypes(Table.SelectRows(T2, each ([USDCAD] <> null)),

                                      {{"Date", type date}, {"USDCAD", type number}})

    in

      T3,

  Last = Table.FirstN(Table.Sort(Clean, {{"Date", Order.Descending}}), 1),

  Result = Table.AddColumn(Last, "CADUSD", each 1/[USDCAD], type number)

in

  Result

This returns the latest business day with both USDCAD and CADUSD.

Tip (single value)
If you need just the last value in a measure:

= Rates_Last[CADUSD]{0}

If this helps, please mark as Accepted Solution and drop a 👍"Kudos"

Thank You Aala Ali, 
I refreshed the report today and it seem the provider fix the issue, where you no longer need to click on "Retrived Data". 

The 1s recommendation was causing the same issue yesterday as I did try to look at it from a daily, monthly, yearly view. , so I would have probably would have gone with your second option at least to get the daily results.

Thanks again for taking the time, I really appreciated.  

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors