cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PedroRibeiro
Level: Powered On

Sharepoint filter by file type/extension

Hi,

I'm trying to create a flow to get only some files.

How can I filter by docx, doc, xls, xlsx, ppt, pptx?

Thanks.

3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Sharepoint filter by file type/extension

Hi @PedroRibeiro,

 

You could get all files information first by using Get files(properties only).

Then use Filter array to filter files, if the file name with the extension ends with the expected file format.

Use endswith() function to make a decision.

Formula reference:

 

@or(endswith(item()?['{FilenameWithExtension}'], '.docx'),endswith(item()?['{FilenameWithExtension}'], '.doc'),endswith(item()?['{FilenameWithExtension}'], '.xls'),endswith(item()?['{FilenameWithExtension}'], '.xlsx'),endswith(item()?['{FilenameWithExtension}'], '.ppt'),endswith(item()?['{FilenameWithExtension}'], '.pptx'))

Image reference:

30.PNG

Please take a try.

 

Best Regards,

Barry

Community Support Team _ Barry
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

Super User
Super User

Re: Sharepoint filter by file type/extension

Hi!

 

There is a better and more effecient way to do this. Filtering result array is time consuming for thouthands of documents.

 

Just use this oData filter under Advanced section of the "Get files" action:

File_x0020_Type eq 'xls'

 

You can find example of usage in this article.

 

This approach is better because it returns only required files.

 

View solution in original post

anton-khrit-hq
Level: Powered On

Re: Sharepoint filter by file type/extension

This should work for you:

File_x0020_Type eq 'xls' or File_x0020_Type eq 'doc' or File_x0020_Type eq 'ppt'

 

I didn't test it.

View solution in original post

6 REPLIES 6
Highlighted
Community Support Team
Community Support Team

Re: Sharepoint filter by file type/extension

Hi @PedroRibeiro,

 

You could get all files information first by using Get files(properties only).

Then use Filter array to filter files, if the file name with the extension ends with the expected file format.

Use endswith() function to make a decision.

Formula reference:

 

@or(endswith(item()?['{FilenameWithExtension}'], '.docx'),endswith(item()?['{FilenameWithExtension}'], '.doc'),endswith(item()?['{FilenameWithExtension}'], '.xls'),endswith(item()?['{FilenameWithExtension}'], '.xlsx'),endswith(item()?['{FilenameWithExtension}'], '.ppt'),endswith(item()?['{FilenameWithExtension}'], '.pptx'))

Image reference:

30.PNG

Please take a try.

 

Best Regards,

Barry

Community Support Team _ Barry
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

PedroRibeiro
Level: Powered On

Re: Sharepoint filter by file type/extension

Barry,

It works.

Thank you.

Super User
Super User

Re: Sharepoint filter by file type/extension

Hi!

 

There is a better and more effecient way to do this. Filtering result array is time consuming for thouthands of documents.

 

Just use this oData filter under Advanced section of the "Get files" action:

File_x0020_Type eq 'xls'

 

You can find example of usage in this article.

 

This approach is better because it returns only required files.

 

View solution in original post

PedroRibeiro
Level: Powered On

Re: Sharepoint filter by file type/extension

@anton-khrit 

Yes I noticed that takes too long because we have multiple files.

With your solution, how can I search for xls, doc, ppt in the same filter? It's possible?

anton-khrit-hq
Level: Powered On

Re: Sharepoint filter by file type/extension

This should work for you:

File_x0020_Type eq 'xls' or File_x0020_Type eq 'doc' or File_x0020_Type eq 'ppt'

 

I didn't test it.

View solution in original post

PedroRibeiro
Level: Powered On

Re: Sharepoint filter by file type/extension

@anton-khrit-hq 

Your solution works perfectly, and is faster.

Thank you.

 

How can I run this in a specific folder inside "Shared Documents"?

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,604)