Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
8 | |
6 | |
6 | |
6 | |
5 |