Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
I have multiple files to be imported from Sharepoint to Power BI through Power Query. The file format is "AAA_yyyymmdd.xlsx". The file are generated from a system, more than once daily. I would like to take only the latest file of each day and append it to Power BI.
I have tried Groupby to get MAX(date created), it is good to go.
Yet, there are certain file with special case that are modified manually before uploaded to Sharepoint and its file name will change to something like "AAA_yyyymmdd.XLSX".
How to include all file that ends with ".XLSX" and the rest just take the latest file of the day? (I have added new column to identify which one is manual file, but do not have better idea to integrate both conditions).
Any help is greatly appreciated.
Hi everyone,
Thank you for helping.
Currently, the best way is using the same method as @Jonvoge, which helps to cover all conditions.
The only slight downside is the loading time due to the increasing file size. So, I have to think another way to do in one single query.
Hi @KJChin
Considering you want to use the latest file from share point folder with file ends with .xlsx. Follow the steps below:
1. Use Share point forder connector. See image :
2. Provide site URL and click ok. See Image :
3. In the next Window, click just transform. See Image:
4. Find the column named "Folder Path". See Image:
5. Click on drop down menu and filter your folder using "Text Filter" option. See Image:
6. My desired folder name is "Test". So, Using "Ends With" and write "Test/" in the value section. You can also filter manually.
7. After filter, go to the column named "Extension" and filter which file you want to include. You said you want only .xlsx. So, filter it. See image (I have 2 different type of files).
8. After filter only .xlsx file, find column named "Date Created". See image below:
9. Again filter only the lastest file. To make it dynamic, click the drop down and select date/time filter and select "Is Latest". See image below:
10. Now delete all column except Binary. Click on the double arrow head icon to extract data. See image below:
Now if I create another file name book3 and refresh, then book2 will be replaced by book3. See image below:
After that you will get below window, just expand data column. See iamge below:
Hope this helps!!
If this solved your problem, Please accept it as a solution!!
Best Regards,
Shahariar Hafiz
Give a try and share you M Code with the issue you encounter and I can have a look.
Hi KJChin
Could you simply create two separate queries, and Union them later on?
That is, one query for handling all the manual files, and one where you filter them out completely and do your grouping?
_____________________________________________________
I hope my comment was helpful.
If your question was answered, please mark your post as 'Solved' and consider giving me a 'Thumbs Up'.
Find me on LinkedIn, Sessionize, or my blog Downhill Data
You solve this in PowerQuery
Use SharePoint.Contents or similar and filer the results. Sort the way you want it with the file you want at the top and then refer to the first row of the result like #"ResultStep"{0}.
Check out this post and it's solution
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 2 |