Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I have a folder connection where I would like to get the newest file only. The first applied step should be to rename the query to the file name, which has a specific prefix and date that identifies the version of the data. The end goal is that each time there is a file update, the file will be dropped into the connected folder via SFTP. Since I cannot overwrite the last file, I want to build the query from the newest file using the file name as updated query name without any human intervention. Here is my current code:
let
Source = Folder.Files("C:\Users\SFowler\OneDrive - Evolent Health, Inc\Continuous Improvement - Code Governance\Artifacts\Source Files\AutomationDiagnosisExpressLookupQuery"),
#"C:\Users\SFowler\OneDrive - Evolent Health, Inc\Continuous Improvement - Code Governance\Artifacts\Source Files\AutomationDiagnosisExpressLookupQuery\_PMWA_Diagnosis_10 31 2023 csv" = Source{[#"Folder Path"="C:\Users\SFowler\OneDrive - Evolent Health, Inc\Continuous Improvement - Code Governance\Artifacts\Source Files\AutomationDiagnosisExpressLookupQuery\",Name="PMWA_Diagnosis_10.31.2023.csv"]}[Content],
#"Imported CSV" = Csv.Document(#"C:\Users\SFowler\OneDrive - Evolent Health, Inc\Continuous Improvement - Code Governance\Artifacts\Source Files\AutomationDiagnosisExpressLookupQuery\_PMWA_Diagnosis_10 31 2023 csv",[Delimiter=",", Columns=19, Encoding=65001, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(#"Imported CSV", [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Diagnosis_Code", type text}, {"Description", type text}, {"Effective_Date", type date}, {"DateTimeModified", type datetime}, {"Termination_Date", type date}, {"Type", Int64.Type}, {"Relation", type text}, {"Action", type text}, {"Entity", type text}, {"Key_1", type text}, {"Key_2", Int64.Type}, {"Key_3", Int64.Type}, {"Key_4", type date}, {"Key_5", Int64.Type}, {"Key_6", Int64.Type}, {"Key_7", Int64.Type}, {"Key_8", Int64.Type}, {"Key_9", Int64.Type}, {"Key_10", Int64.Type}})
in
#"Changed Type"
To clarify, this code is working, I just need to modify it to include the two steps:
Solved! Go to Solution.
You can't dynamically rename a query with M code.
--Nate
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.