cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Asamadi Regular Visitor
Regular Visitor

Append web data in a specific table based on list of Dates

I want to write a query in power bi desktop and get data from this link:

http://www.xe.com/currencytables/?from=USD&date=2017-12-12

but my question is, how can i write a query that append new data from the link, based on the date of my windows or list of dates in a table and append to my table. 

another thing is i want it add a column that is the current date or th list of dates in a tableCapture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft v-ljerr-msft
Microsoft

Re: Append web data in a specific table based on list of Dates

Hi @Asamadi,

 

According to your description above, it seems to be that you want to get history data of a range of dates(i.e. from 2017-12-01 to 2017-12-12) from that web site, right?

 

If that is the case, you can firstly create a function named "GetData" to get data of a specific date from that site.

(date1 as date) as table =>
let
    Source = Web.Page(Web.Contents("http://www.xe.com/currencytables/?from=USD&date="&Date.ToText(date1,"yyyy-MM-dd"))),
    Data = Source{0}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Data,{{"Currency code ▲▼", type text}, {"Currency name ▲▼", type text}, {"Units per USD", type number}, {"USD per Unit", type number}})
in
    #"Changed Type"

Then use the formula below to create a new query to get all data from the date range which you can specify in the query.

let
    Source = List.Dates(#date(2017, 12, 1), 10, #duration(1, 0, 0, 0)),
    ToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Renamed = Table.RenameColumns(ToTable,{{"Column1", "Date"}}),
    Added = Table.AddColumn(Renamed, "Custom", each GetData([Date])),
    #"Expanded Custom" = Table.ExpandTableColumn(Added, "Custom", {"Currency code ▲▼", "Currency name ▲▼", "Units per USD", "USD per Unit"}, {"Custom.Currency code ▲▼", "Custom.Currency name ▲▼", "Custom.Units per USD", "Custom.USD per Unit"})
in
    #"Expanded Custom"

r2.PNG

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

1 REPLY 1
Microsoft v-ljerr-msft
Microsoft

Re: Append web data in a specific table based on list of Dates

Hi @Asamadi,

 

According to your description above, it seems to be that you want to get history data of a range of dates(i.e. from 2017-12-01 to 2017-12-12) from that web site, right?

 

If that is the case, you can firstly create a function named "GetData" to get data of a specific date from that site.

(date1 as date) as table =>
let
    Source = Web.Page(Web.Contents("http://www.xe.com/currencytables/?from=USD&date="&Date.ToText(date1,"yyyy-MM-dd"))),
    Data = Source{0}[Data],
    #"Changed Type" = Table.TransformColumnTypes(Data,{{"Currency code ▲▼", type text}, {"Currency name ▲▼", type text}, {"Units per USD", type number}, {"USD per Unit", type number}})
in
    #"Changed Type"

Then use the formula below to create a new query to get all data from the date range which you can specify in the query.

let
    Source = List.Dates(#date(2017, 12, 1), 10, #duration(1, 0, 0, 0)),
    ToTable = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
    Renamed = Table.RenameColumns(ToTable,{{"Column1", "Date"}}),
    Added = Table.AddColumn(Renamed, "Custom", each GetData([Date])),
    #"Expanded Custom" = Table.ExpandTableColumn(Added, "Custom", {"Currency code ▲▼", "Currency name ▲▼", "Units per USD", "USD per Unit"}, {"Custom.Currency code ▲▼", "Custom.Currency name ▲▼", "Custom.Units per USD", "Custom.USD per Unit"})
in
    #"Expanded Custom"

r2.PNG

 

Here is the sample pbix file for your reference. Smiley Happy

 

Regards

View solution in original post

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors