Use Power Query to Load a File Based on a Dynamic Date in Excel
Question details
The user wants to configure Power Query to dynamically download a daily file by constructing a URL that references a date typed into a specific Excel cell.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Automating the retrieval of daily reports (like ZIP files) from a web server where the file URL changes based on the date.
- Observed behavior
- The user aims to eliminate manual URL editing in Power Query by connecting the query directly to an Excel cell, allowing data to be updated automatically upon refresh.
Ensure you know the exact URL structure required to download the file and that the source website allows direct automated downloads without manual authentication blocks.
Create a Dynamic URL Parameter in Power Query
By turning an Excel cell into a named range and passing it into Power Query as a variable, you can dynamically construct your download URL using the Web.Contents function.
This solution involves linking a specific worksheet cell to your Power Query setup. You will first isolate the date, convert it into a properly formatted text string, and then concatenate it into the target web address.
Select the cell in your Excel workbook where you will enter the date. Click inside the Name Box (to the left of the formula bar), type 'DateInput', and press Enter.
With the cell selected, go to the Data tab and click 'From Table/Range'. Once the Power Query Editor opens, right-click the date value in the preview and select 'Drill Down' to convert the table into a single value.
In the Power Query Editor, go to Home > Advanced Editor. Locate the step referencing your date and convert it into text using a function like Date.ToText(Source, "ddMMyyyy"). Make sure the format matches the requirements of your target URL.
In the Advanced Editor, create a new variable that merges your base URL with the formatted date. For example: DynamicUrl = "https://example.com/data_" & DateString & ".zip".
Add a final step using Web.Contents(DynamicUrl) to download the file. If it is a ZIP file, apply the necessary extraction functions, then click 'Close & Load' to return the data to your Excel workbook.

A Lightweight Alternative for Your Daily Spreadsheet Tasks
If complex Power Query setups and data connections are causing Microsoft Excel to run slowly, consider trying WPS Office. It provides a highly compatible, lightweight spreadsheet alternative for processing daily data without the heavy system requirements.
- 1. Download WPS Office: Visit the official WPS website and download the free WPS Office installer.
- 2. Open Your Spreadsheets: Launch WPS Spreadsheet and open your existing .xlsx files directly without any conversion.
- 3. Manage Data Easily: Use the familiar Data tab to sort, filter, and analyze your daily imported information effortlessly.

Frequently Asked Questions
How do I refresh the data after entering a new date in Excel?
After typing the new date into your designated cell, simply go to the Data tab on the Excel ribbon and click 'Refresh All'. Power Query will rebuild the URL and pull in the corresponding file.
Why am I getting a 'Formula Firewall' error in Power Query?
This error happens when Power Query tries to combine local data (your Excel cell) with external data (the web URL). To resolve this, go to File > Options and settings > Query Options > Privacy, and select 'Always ignore Privacy Level settings'.
Can I use this method to download CSV or Excel files instead of ZIPs?
Yes. The Web.Contents function can fetch any file type. You just need to ensure your M-code URL string ends with the correct file extension (.csv or .xlsx) and apply the proper parsing steps in Power Query after downloading.
What if the website URL requires the date in a YYYY-MM-DD format?
You can easily adapt the URL structure in the Advanced Editor. Simply change the formatting string in your conversion step to Date.ToText(Source, "yyyy-MM-dd") to match the exact URL requirements.




