Filtering a SharePoint List View by Hyperlink

I recently had a need to filter a SharePoint list view by a hyperlink column and found that unlike most column types in SharePoint, the edit view UI did not provide me with the ability to filter by this column type. It’s an odd choice, but… ok? As it turns out, you can actually create filters on these column types, you’re just limited to having to do this via SharePoint Designer.

In my case, I was doing this in 2010, but imagine it’s virtually identical in 2013 / Office 365. Essentially, you just create your view as normal, and when you’re all set, you just add the filter at the end.

  1. Create your view in the GUI
  2. Add a sort (if desired)
  3. Save the view
  4. Launch SharePoint Designer and load the view you just created
  5. In the code for the view, look for an element named <Query> (note: if you can’t find a Query element, you likely didn’t add a sort above, this is fine, just create your own opening and closing <Query> elements like you see below – immediately below the <View> element).
  6. In the Query element, Add a <Where> statement, like the one you see below. In my case what this will do is filter on the “Document” column (which is a hyperlink – yes, it’s a hyperlink to a document) and will include all results where the Document column is null (or empty, or blank, or however you want to think of it).


As you can see below, the result is all the items where the Drawing column is empty.


There are many possible forms of using <Where> statements, all of these below are valid statements:

Below we’ll filter for all documents which contain a “.pdf” in the URL.

<Where>

<Contains>

<FieldRef Name=”Document”/>

<Value Type=”Text”>.pdf</Value>

</Contains>

</Where>

Here we’ll filter where all the Document2 results are not null while simultaneously ensuring all the Document results are null.

<Where>

<And>

<IsNotNull>

<FieldRef Name=”Document2″/>

</IsNotNull>

<IsNull>

<FieldRef Name=”Document”/>

</IsNull>

</And>

</Where>

Feel free to look up the syntax for view filtering and come up with your own filter statements.

[Update]

You can also view a video that Webucator produced on this topic here.

Thanks Webucator!
[/Update]

One response to “Filtering a SharePoint List View by Hyperlink

  1. Thank you! Surprised SharePoint doesn’t simply allow Hyperlink field filtering if it’s this easy to do with SharePoint Designer.

Comments are closed.