cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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
Community Support

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

Highlighted
Helper V
Helper V

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

Highlighted
Regular Visitor

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
Community Support

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

Highlighted
Frequent Visitor

Re: Sharepoint filter by file type/extension

Barry,

It works.

Thank you.

Highlighted
Helper V
Helper V

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

Highlighted
Frequent Visitor

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?

Highlighted
Regular Visitor

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

Highlighted
Frequent Visitor

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
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Users online (8,636)