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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
JyoVennela
New Member

Import Dynamic CSV files based on input date from the NAS folder

Hi Team,

 

I have file to import in the Power BI which gets updated everyday ,and file name changes with date string on it.I want to import the file of last date on it.

 

For example today (02/10/2018)I have a file to import is

report_20180209.csv

next date(02/11/2018) i want the imported file to be

report_20180210.csv

 

I am trying to find out the proper way create parameter based on date

 

Thanks for your help

2 REPLIES 2
JyoVennela
New Member

Thanks for sharing the detailed steps.
I could be able to do it in the Power BI Desktop, it is loading the file based on the date parameter but i can't find the input the date, once it is published to "Power BI Service". Will it be feasible to do it in Power BI Desktop?

As a beginner,it might be a basic question that I want something like based on the end user input date selection from the Power BI Service, it has to load the respective file from the source location.  eg: Let's say in the below screen shot, if the end user selects a value from the dropdown then click on "view Report" then it has to load the respective file

JyoVennela_0-1695340802019.png

 

Really appreciate your help.

 

Thanks

 

123abc
Community Champion
Community Champion

To import dynamic CSV files based on the input date from a NAS folder in Power BI, you can follow these steps:

1. **Create a Parameter for Date Input:**
- Go to the "Home" tab in Power BI.
- Click on "Manage Parameters" in the "External Data" group.
- Click on "New Parameter."
- Name the parameter something like "SelectedDate."
- Choose "Date/Time" as the data type.
- Set the allowable values to "List of values."
- Define the list of values as the dates for which you have files in your NAS folder. You can manually input these dates or generate them programmatically based on your specific requirements.

2. **Create a Custom Column for File Name:**
- In the Power Query Editor, select the table where you want to store the file names.
- Add a custom column using the "Add Column" tab.
- Use the following formula to generate the file name based on the selected date parameter:
```
"report_" & Text.From(Date.Year([SelectedDate])) & Text.PadStart(Text.From(Date.Month([SelectedDate])), 2, "0") & Text.PadStart(Text.From(Date.Day([SelectedDate])), 2, "0") & ".csv"
```
- Replace `[SelectedDate]` with the actual name of your date parameter.

3. **Load the Data:**
- Make sure that the table with the file names is enabled for load (check "Enable Load").
- Load the data into Power BI.

4. **Dynamic File Import:**
- Now that you have the file names generated based on the selected date parameter, you can create a new query that uses the generated file name to import the corresponding CSV file.
- Create a new query by going to "Home" > "Close & Apply" > "New Source" > "File."
- In the "File" dialog, select the folder where your CSV files are stored.
- In the "File Name" field, use the generated file name from your previous step by referencing the custom column you created. For example, `[GeneratedFileName]`.

5. **Load and Combine Data:**
- Load the data from the selected CSV file into Power BI.
- You can then transform, combine, or append this data as needed in your Power Query.

With these steps, you'll be able to dynamically import the CSV file based on the selected date parameter in Power BI. Each time you change the date parameter, Power BI will use the generated file name to load the corresponding CSV file.

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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