Filtering a list view is a good way for displaying data within a list or document library. However, you're limited to what the SharePoint interface allows you to filter by. You can create complex filters using AND and OR, but there's one issue: the expression are evaluated in order and doesn't allow any sort of order to be forced. If you can not install a feature or produce code behind, here is a technique to change the view.
Sample
Suppose I had two fields, Party and Guests, in my SharePoint list and I wanted to filter a view like this:
When Party = Saturday and Guests > 2, or when Party = Monday and Guests > 6.
In code, it would appears as such:
(Party = Saturday && Guests > 2) || (Party = Monday && Guests > 6)
The problem is that the query is not built that way. Instead I'd get:
(((Party = Saturday && Guests > 2) || Party = Monday) && Guests > 6)
The result is that saturdays parties with six guests or more should appear in my filtered list, just because the last clause Guests > 6 overrides that for the Saturday Guests >2.
Solution
This is where SharePoint Designer is usefull. I can build the CAML query for the Where clause appropriately to capture the logic that you are looking for. The original Where clause will look something like this:
<where>
<And>
<Or>
<And>
<Eq><FieldRef Name="Party"/><Value Type="Text">Saturday</Value></Eq>
<Gt><FieldRef Name="Guests"/><Value Type="Number">2</Value></Gt>
</And>
<Eq><FieldRef Name="Party"/><Value Type="Text">Monday</Value></Eq>
</Or>
<Gt><FieldRef Name="Guests"/><Value Type="Number">6</Value></Gt>
</And>
</where>My Where clause will need to be changed to look like this:
<where>
<Or>
<And>
<Eq><FieldRef Name="Party"/><Value Type="Text">Saturday</Value></Eq>
<Gt><FieldRef Name="Guests"/><Value Type="Number">2</Value></Gt>
</And>
<And>
<Eq><FieldRef Name="Party"/><Value Type="Text">Monday</Value></Eq>
<Gt><FieldRef Name="Guests"/><Value Type="Number">6</Value></Gt>
</And>
</Or>
</where>Once you build your query offline, you'll need to search for and replace the old query with your new one. Note that the XML is encoded as text, so < and > characters are encoded as < and >, respectively. Use your favorite notepad to set your query appropriately.
Final word
Note that, if you need to change something in your view (order of fields, grouping,
sorting, etc), then SharePoint will rewrite your query with what it thinks is correct.
In this example, it will replace your query with what it was before. You'll just
need to make sure that your view is set up correctly before updating the query manually.