Update Data from Web

smitpau

Board Regular
Joined
Apr 2, 2020
Messages
143
Office Version
  1. 365
Platform
  1. Windows
Hi,

I'd like to be able to update the data from the web based on a cell URL link.

The reason for this is if you look at the example below there is a specific date, this date will change over time (as only require a certain amount of history, say 1 year).

So ideally the web lookup would be dynamic but I can only seem to put a fixed URL into the from Web data source.

Hope that explains the issue clearly, any help appreciated, thanks for reading!


Example URL:
Original - https://api.exchangeratesapi.io/201...D,JPY,CHF,CAD,CNY,HKD,NZD,TRY,INR,BRL,ZAR,PLN
Updated (based on cell) - https://api.exchangeratesapi.io/201...D,JPY,CHF,CAD,CNY,HKD,NZD,TRY,INR,BRL,ZAR,PLN
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

smitpau

Board Regular
Joined
Apr 2, 2020
Messages
143
Office Version
  1. 365
Platform
  1. Windows
Ah yes that's what I'm after thanks.

It wouldn't necessarily need data validation though as the cell dates would auto-updated (so that 31/08/2019 would be 30/09/2019).

Not sure if that would cause a problem.

PS it's quite cool, haha.
 

smitpau

Board Regular
Joined
Apr 2, 2020
Messages
143
Office Version
  1. 365
Platform
  1. Windows
I don't get why changing that data validation cell changes the table, if you don't mind explaining probably quicker than me trying to back work it.
 

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,497

ADVERTISEMENT

you can remove DV and enter dates manually or somehow but the table should stay there (or moved to another place via drag&drop)

I don't get why changing that data validation cell changes the table, if you don't mind explaining probably quicker than me trying to back work it.
MAGIC ! :biggrin: :biggrin: :biggrin:
open Power Query Editor then Advanced Editor and you'll see why and how it works
 

smitpau

Board Regular
Joined
Apr 2, 2020
Messages
143
Office Version
  1. 365
Platform
  1. Windows
I've tried amending the table into the format I had in mind.



If I try the code below it comes up with this error might be because it's trying to return multiple dates.

Expression.Error: The column 'Date' of the table wasn't found.
Details:
Date

Attempted code (bold=Change):

let
Source = Excel.CurrentWorkbook(){[Name="[B]FX_List[/B]"]}[Content],
Date = Table.TransformColumnTypes(Source,{{"Date", type date}}){0}[Date],
Json = Json.Document(Web.Contents("https://api.exchangeratesapi.io/"&Date.ToText(Date,"yyyy-MM-dd")&"?base=GBP&symbols=EUR,SGD,USD,AUD,JPY,CHF,CAD,CNY,HKD,NZD,TRY,INR,BRL,ZAR,PLN")),
rates = Json[rates],
C2T = Record.ToTable(rates)
in
C2T

It
 

sandy666

Banned - Rules violations
Joined
Oct 24, 2015
Messages
7,497

ADVERTISEMENT

Power Query works with columns and content

btw. why you enter this format date: 2016/08/31 ?
 

smitpau

Board Regular
Joined
Apr 2, 2020
Messages
143
Office Version
  1. 365
Platform
  1. Windows
Ah okay I see yours is the other way round, it's because that was the way the API used the date formatting but I see the code adjusts for that anyway.

I'll change to that format and see what happens.
 

Watch MrExcel Video

Forum statistics

Threads
1,133,426
Messages
5,658,727
Members
418,467
Latest member
sc356448

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top