Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
10 | |
8 | |
6 | |
6 | |
6 |