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!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi Community,
I have a requirement where I have to pull files from the folder and combine all the files into Source. There are contents of previous file in each file. For instance, If I have data for dates 1-5 on file1, file2 will have contents of 2-6, and file3 will have 3-7 and so on.... the file name will be the timestamp. Since there is no unique column, I planned to sort the files by file name and use filtering only the lastest date of the file for other files except the first file wile combining. I struck on filtering the date as the dates will be dynamic as the number of files added will increase. Is there any idea for filtering based on date. Thanks in advance.
Regards
Fazil M
Solved! Go to Solution.
1, combine all the data without any filters and keep the filenames
2, add a new step with this code
=Table.Combine(Table.Group(Source,"date",{"n",each List.Last(Table.Group(_,"filename",{"t",each _})[t])})[n])
To achieve this, where each file has overlapping data, and you need to filter based on the latest date, you can follow this approach:
Combine All Files:
Add a Date Column:
Sort Files by Timestamp:
Filtering Logic:
Dynamic Date Filtering:
let
// Load files from folder
Source = Folder.Files("C:\\YourFolderPath"),
// Combine files
CombinedData = Table.Combine(Source[Content]),
// Add timestamp column or use file name if needed
AddTimestamp = Table.AddColumn(CombinedData, "FileTimestamp", each DateTime.FromText(Text.Middle([Name], 0, 19))),
// Sort by timestamp
SortedData = Table.Sort(AddTimestamp,{{"FileTimestamp", Order.Ascending}}),
// Remove duplicates, keeping the latest date from each file
RemoveDuplicates = Table.Distinct(SortedData, {"DateColumn", "FileTimestamp"})
in
RemoveDuplicates
This approach ensures that even as new files are added, only the latest date from each file is included in the final dataset.
Would you like more details on implementing this solution or troubleshooting any step?
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Please Subscribe my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
Hi @Poojara_D12
Thanks for the reply. I have tried @wdx223_Daniel method and got the answer I expected. I'll try this and once worked I'll let you know.
Regards
Fazil M
1, combine all the data without any filters and keep the filenames
2, add a new step with this code
=Table.Combine(Table.Group(Source,"date",{"n",each List.Last(Table.Group(_,"filename",{"t",each _})[t])})[n])
Hi @wdx223_Daniel
I have Tried this and this works perfectly. Thanks
Regards
Fazil M