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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Brand
Frequent Visitor

Calculate the pdf-files in a sharepoint subfolder (created every week)

Dear BI heroes!

 

I do not know if it is possible, but I would like to get some specific data out of Sharepoint.

 

I would like to know how much PDF-files are in a specific subfolder, but this subfolder changes every week.
This is because every week there will be new set of automatiscally generated pdf-files in a subfolder named after the weeknumber. For example: Year 2023/Week 39/ <PDF_FILE(s)>.

 

Results I would like:
Every monday we will need the number of PDF-files in the subfolder of last week. So today (8-7-2023, week 32) we would like to see (quantity) how much PDF-files are uploaded to the folder 31 (last weeks folder).

 

I'am using a default sharepoint import source in Power BI, but cannot seem to find a "easy" way to get the data...

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Brand ,

To get the number of PDF-files in the subfolder of last week, you can try to use the SharePoint REST API to query the folder and filter by the creation date of the folder. Please try the steps:

1. Use the following URL to get the list of subfolders in the parent folder: `https://<your_sharepoint_site>/_api/web/GetFolderByServerRelativeUrl('<parent_folder_url>')/folders`

2. Loop through the subfolders and find the one with the creation date of last week. You can use the `Created` property of the folder to filter by date.

3. Once you have the subfolder for last week, use the following URL to get the list of PDF-files in the subfolder: `https://<your_sharepoint_site>/_api/web/GetFolderByServerRelativeUrl('<subfolder_url>')/files?$filter=File_x0020_Type eq 'pdf'`

4. The number of PDF-files in the subfolder can be obtained from the `__metadata.count` property of the response.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @Brand ,

To get the number of PDF-files in the subfolder of last week, you can try to use the SharePoint REST API to query the folder and filter by the creation date of the folder. Please try the steps:

1. Use the following URL to get the list of subfolders in the parent folder: `https://<your_sharepoint_site>/_api/web/GetFolderByServerRelativeUrl('<parent_folder_url>')/folders`

2. Loop through the subfolders and find the one with the creation date of last week. You can use the `Created` property of the folder to filter by date.

3. Once you have the subfolder for last week, use the following URL to get the list of PDF-files in the subfolder: `https://<your_sharepoint_site>/_api/web/GetFolderByServerRelativeUrl('<subfolder_url>')/files?$filter=File_x0020_Type eq 'pdf'`

4. The number of PDF-files in the subfolder can be obtained from the `__metadata.count` property of the response.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors