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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Mikey575
Frequent Visitor

Importing Specific csv files from a folder.

I want to import specific .csv files from a folder and need it to be dynamic so i dont have to move any files or change the name file. I also need the dates to dyamically move on each month so once we get past a quarter end it picks up the file with that date.

 

The files have a date at the end of their title so can be differenciated by that. They are monthly files (dated last day of month) but i only want to import ones that have a Quarter end. Removing the files that arent needed from the folder isnt an option.

 

So in the list below of all the files in the folder i only want to import the ones with the dates in the title of 20230331, 20230630, 20230930:

 

CompanyAUMData_20230131.csv

CompanyAUMData_20230231.csv

CompanyAUMData_20230331.csv

CompanyAUMData_20230430.csv

CompanyAUMData_20230531.csv

CompanyAUMData_20230630.csv

CompanyAUMData_20230731.csv

CompanyAUMData_20230831.csv

CompanyAUMData_20230930.csv

CompanyAUMData_20231031.csv

 

I am guessing it would mean the use of parameters but am happy to try any method.

3 REPLIES 3
ERD
Community Champion
Community Champion

@Mikey575 , you might use a Date table in Power Query and via adding/removing extra columns achieve the result. I just took the names, but the logic is similar, just copy/paste and go through steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WUorViVZyzs8tSMyrdAz1dUksSYw3MjAyNjAystBLLi4Dy+NUZGxsSFiRibEBYUWmxJhkRoxJ5sSYZEGMIksirDM0gJkUCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CompanyAUMData_20230131.csv = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([CompanyAUMData_20230131.csv] <> "")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "dt", each [CompanyAUMData_20230131.csv]),
    #"Extracted Text After Delimiter" = Table.TransformColumns(#"Added Custom", {{"dt", each Text.AfterDelimiter(_, "_"), type text}}),
    #"Extracted Text Before Delimiter" = Table.TransformColumns(#"Extracted Text After Delimiter", {{"dt", each Text.BeforeDelimiter(_, "."), type text}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Extracted Text Before Delimiter", {{"dt", type date}}, "en-CH"),
    #"Merged Queries" = Table.NestedJoin(#"Changed Type with Locale", {"dt"}, Date, {"Date"}, "Date", JoinKind.LeftOuter),
    #"Expanded Date" = Table.ExpandTableColumn(#"Merged Queries", "Date", {"End of Quarter"}, {"Date.End of Quarter"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Date", "check", each [dt] = [Date.End of Quarter]),
    #"Filtered Rows1" = Table.SelectRows(#"Added Custom1", each ([check] = true)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows1",{"dt", "Date.End of Quarter", "check"})
in
    #"Removed Columns"

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Daryl-Lynch-Bzy
Resident Rockstar
Resident Rockstar

Hi @Mikey575 - Yes there is.  If you connect to the excel file using the File.Contents - PowerQuery M | Microsoft Learn or SharePoint.Files - PowerQuery M | Microsoft Learn you will be provided with all the Excel files in the selected folder path.  This is presented in a standard table, so you can apply transformations to filename.   This will allow you to find add a column with Date of the file.  You can then apply any filters to select files.

@Daryl-Lynch-Bzy Thank you for your respose Daryl. I could get what you suggested to work but i can see its on the right lines. Please could you give me some more detail?

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.

Top Solution Authors