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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.