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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Rebecca6634
Frequent Visitor

Importing a csv with dynamic url from a webpage

Hi

 

I'd like to set up a query that automatically extracts the most recent versions of these csv documents from the below webpages. The csvs change each week and I need the report to work with scheduled refresh.

 

I have previously set up a query to import a csv/xlxs using a dynamic date, but I wonder if there is a better way to do this? The NHS files in particular are tricky as other parts of the url string change randomly each week rather than just the date.

 

Can anyone advise if there is an easy way to achieve this? Thanks

 

https://www.ons.gov.uk/peoplepopulationandcommunity/healthandsocialcare/causesofdeath/datasets/death...

 

https://digital.nhs.uk/data-and-information/publications/statistical/mi-potential-covid-19-symptoms-...  (csv files are in the Resources section towards the bottom of the page)

1 REPLY 1
lbendlin
Super User
Super User

Here's one way of approaching this

 

let
    Source = Date.WeekOfYear(DateTime.FixedLocalNow()),
    Weeks = {Source-30..Source},
    #"Converted to Table" = Table.FromList(Weeks, Splitter.SplitByNothing(),  {"Week"},null, ExtraValues.Error),
    #"Added Custom" = Table.AddColumn(#"Converted to Table", "URL", each try Excel.Workbook(Web.Contents("https://www.ons.gov.uk/file?uri=/peoplepopulationandcommunity/healthandsocialcare/causesofdeath/datasets/deathregistrationsandoccurrencesbylocalauthorityandhealthboard/2020/lahbtablesweek" & Text.From([Week]) & ".xlsx")) otherwise null)
in
    #"Added Custom"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.