Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join 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.

Reply
romankorchak
Frequent Visitor

Is there API equivalent for SharePoint.Files function

Hi All

I am still trying to find the best way to get a list of old files, older then certain date, from sharepoint sites

And the quickiest way so far is to use SharePoint.Files function in the power query to build power bi report - it gets all the files in one go and doesnt complain about 5000 limit threshould 

But we have a few thousанds sites and need to get that report for all of them, so I am wandering if there are an API equivalent for SharePoint.Files power query function so I can use it in a flow or powershell script 

I have tried SharePoint "_api/web/lists/GetByTitle('Documents')/items?$filter" but it complains about list view threshold

Any ideas?

Thanks

4 REPLIES 4
christinepayton
Super User
Super User

IMO, if your end goal is to help users clean out old content, you might be better off to use PowerShell to create a view on all the libraries that shows items outside of folders, sorted aescending by modified date. That would give people a view to directly clean up old files inside their site, instead of referencing a report, then cross-checking on filename in the libraries. This is assuming you are asking users to clean it up and not programmatically removing files. 

 

If you hit the list view threshold with this, you can set a date filter on it, like last modified < [Today] - 1000 to show only things that are super old - that usually cuts down the size substantially. 

Main goal is to get a report of how many/total size of old files in each site. I do have a powershell script that loops through eatch site to gather that info, but it takes weeks to complete (as its going through each site folder to check for old files ).
   Regarding the view threshould - that API link gives "The attempted operation is prohibited because it exceeds the list view threshold" error even if the site has more than 5000 files in total but less than 5000 old files, so its checking for a threshold limit before filtering  

Greg_Deckler
Super User
Super User

@romankorchak Can you just wrap it in a custom function with a single parameter, import a list of your sites and then just add a column that calls the function with the site URL? Then just expand that column.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

I did think of that, but we have around 4000 sites with few k to few 10k old files per site, so if I load all of it into one pbi report its will just crash. unles there is a way (which I dont know of) to save old files list into csv/db per each site in a looping through sites, so do something like
 

foreach(site in sites){
   save list of old files in the site into csv or database 
} 

in a PBI DataSet (we have a Fabric so could do it in the dataflow)
 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.