Power Automate to filter files in SharePoint by file name

“I’m trying to filter files in SharePoint by the file name but Power Automate tells me that column ‘Name’ doesn’t exist.”

“Column ‘Name’ does not exist. It may have been deleted by another user.”


When using ‘Get files’ in Power Automate, you get the file ‘Name’ dynamic content as an output, but that doesn’t mean there’s a column called ‘Name’ you could use in the OData Filter Query. As always, it’s not important how the dynamic content is called, but what is behind. And behind the dynamic content ‘Name’ is a value ‘{Name}’.

Power Automate file name internal name

In many situations that would be the column internal name the Filter Query expects, but not here. You can’t use the ‘{Name}’ in the Filter Query as you’d end up with another error message: The $filter expression “{Name} eq ‘xxxx'” is not valid. Creating query failed. To filter by the file name you need a bit of SharePoint background knowledge.

Document library internal names

SharePoint has a set of hidden internal names used on document libraries. They don’t appear in the file properties so it’s hard to find them, but they’ve been in SharePoint since “ancient” versions. The ones I consider most important for filtering in Power Automate are in the table below.

Internal nameDescriptionExample data
FileLeafRefName of file including extensionExampleFile.docx
FileRefServer relative URL path of the filesites/Playground/Shared Documents/20201231/ExampleFile.docx
File_x0020_TypeFile typedocx

Use FileLeafRef instead of Name

As you can see in the table above, file name including extension is hidden behind ‘FileLeafRef’ column. If you use that column in the OData Filter Query you’ll get the file you’re looking for.

FileLeafRef eq 'FileNameWithExtension'

Note: don’t forget the single quotes around the file name. It doesn’t matter if you use dynamic content or typed-in value, it’s needed in both cases.

The example ‘Get files’ action on the screenshot above will return only file test.csv (if it exists). You can use the same column, only with different operator, also to find files with a string in the file name.

Summary

Filtering files from a document library is a rare situation when Power Automate won’t give you a hint. In most situations you can find the internal name in the list/library settings or in the action output. Not so with the default columns in a document libraries. Unless you know the columns internal names, you won’t be able to use the OData Filter Query.

I believe it’s worth filtering directly in the ‘Get files’ action whenever possible, and the 3 internal names from this article should give you all you need.

It is not the only way to find a file, there’s also a solid workaround to get all files and then filter using ‘Filter Query’ action. But then you must get back the dynamic content after the filtering and I prefer to keep my flows simple.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to a special content like a SharePoint Filter Query cheat sheet.

Zero spam, unsubscribe anytime.

Add a Comment

Your email address will not be published. Required fields are marked *