Scenario/Problem:
You want to limit the view so that it shows only items with certain
values in certain columns. For example, a common requirement is to
display announcements until a certain date, when they then expire.
Solution:
Filters determine what items or files are displayed in a view, based on
the data that is in the columns. A solution to this problem would be to
create a column for the expiration date and add a filter to the view
that displays only the announcements whose expiration dates are in the
future.
To define filter criteria for a view, scroll in the view creation page to the Filter section (see Figure 1). By default, no filter is applied on a new view, so the view displays all items.
FIGURE 1 The Filter section in the view creation page.
To define a filter, use the column picker
drop-down menu and select the column based on which you want to filter
items. Then choose the operator that you want for the filter and the
value you want to use for the comparison. For example, if you want to
filter a view to display only items that have a title (excluding the
items that do not have a value in the Title column), choose the Title
column in the column drop-down menu, select Is Not Equal To, and leave
the value box empty (see Figure 1). This forms the condition Title Is Not Equal to Nothing.
Note
Not all columns can be filtered. The column
picker drop-down menu shows only columns that support filtering. For
example, columns of type Hyperlink do not support filtering and are not
shown in the column picker drop-down.
Another example for a
filter you might want to create on a view would be items that you or
another person created. The simplest way to do this is to choose the
Created By column in the column drop-down menu, select the Is Equal To
operator, and then enter the name of the person you want (either you or
anyone else) in the value box (see Figure 2).
FIGURE 2 Setting a filter for the Created By column by typing the name of the person.
When you browse to the
new view, the documents (or list items) are displayed only if they were
created by a user with exactly the same name that you typed (in this
example, Jane Doe).
If you want the filter to be dynamic and
change based on the person, you can use a token instead of typing the
person’s actual name. For example, you can use the [Me] token instead
of the value; this is replaced with the name of the user viewing the
view and is not limited to a name you chose beforehand (see Figure 3).
FIGURE 3 Setting a filter for a view that displays for every user his or her documents, using the [Me] token.
This capability is useful when you want to
set up a public view (for everyone to use) so that anyone visiting the
view can see his or her documents or items without requiring you to
create a view for each person separately.
Note
Another useful token is [Today]. For date
fields, it is replaced with the current date. With this token, you
could create a view that displays only the documents or items created
or modified today, or in a tasks list, you could show all the items
that are due today.
You can add, or chain, up to 10 filter
conditions in each view. To add an additional filter condition, first
decide how the filter will be added—using either the AND or the OR
operators. You use the OR operator when you want the items or files to
be displayed if they match at least one of the filter conditions.
For example, you can set the first filter
column to Created By Is Equal to John Doe and use the OR operator to
add the second filter column, Created By Is Equal to Jane Doe (see Figure 4). This condition sets the view to display only documents that were created by either John Doe or Jane Doe.
FIGURE 4 Setting up two filters, using
the OR chaining operator to show documents that were created by either
John Doe or Jane Doe.
By using the AND chaining operator, you can
create conditions such as Created By Is Equal to John Doe and Created
Is Equal to Today. This operator restricts the view to display only
documents that match both filters. Another example would be to create
the filters Created By Is Not Equal to John Doe and Created By Is Not
Equal To Jane Doe (see Figure 5). When viewing this view, the users see all files (or items) that have been created by users other than John Doe or Jane Doe.
FIGURE 5 Adding another filter criterion and joining the criterion with the AND chaining operator.
You can continue and add up to 10 filters, as
mentioned earlier. To add additional filters after the first two, use
the Show More Columns link below the last filter. Every time you click
this link, a new filter criterion section appears.
If you want to remove a condition from the
filter, just change the column in the column picker drop-down menu to
None. Even though the condition section still shows, the filter does
not have that condition when you save the view.
Tip
Chaining a lot of conditions can be
confusing. The most common mistake people make is choosing AND instead
of OR or vice versa. Make sure you select not only the right operator
and value but also the right chaining operator.