Microsoft KB Archive/132462

= PRJ: Filter with Many Conditions Produces Unexpected Results =

Article ID: 132462

Article Last Modified on 11/25/2003

-

APPLIES TO


 * Microsoft Project 4.1 Standard Edition
 * Microsoft Project 3.0 Standard Edition
 * Microsoft Project 3.0a
 * Microsoft Project 4.0 Standard Edition
 * Microsoft Project 3.0 for Macintosh
 * Microsoft Project 4.0 for Macintosh

-



This article was previously published under Q132462



SUMMARY
When you create a filter with multiple conditions and not all entries in the And/Or column are the same, you may get unexpected results.

The filter definition dialog box has neither a way of grouping conditions by priority nor an order of precedence. Instead, conditions are grouped according to the order in which they appear in the dialog box.



MORE INFORMATION
Filter conditions are evaluated solely on the basis of their sequential order in the filter dialog box.

Consider the following examples:

Example 1
The following information is evaluated as:   Flag1     Equals    Yes    And Flag2    Equals    Yes    Or   Flag3     Equals    Yes    Or   Flag4     Equals    Yes    And Flag5    Equals    Yes is interpreted as   ((Flag1 Equals Yes And Flag2 Equals Yes) Or Flag3 Equals Yes Or Flag4   Equals Yes) And Flag5 Equals Yes rather than:   (Flag1 Equals Yes And Flag2 Equals Yes) Or Flag3 Equals Yes Or (Flag4   Equals Yes And Flag5 Equals Yes)

Example 2
The following information   Flag1     Equals    Yes    Or   Flag2     Equals    Yes    And Flag3    Equals    Yes    And Flag4    Equals    Yes    Or   Flag5     Equals    Yes is interpreted as   (((Flag1 Equals Yes Or Flag2 Equals Yes) And Flag3 Equals Yes) And   Flag4 Equals Yes) Or Flag5 Equals Yes and not:   (Flag1 Equals Yes Or Flag2 Equals Yes) And Flag3 Equals Yes And (Flag4 Equals Yes Or Flag5 Equals Yes) Using example 2, another way to look at how filter conditions are evaluated is:            (Flag1  Equals  Yes) = Result1 Result1 Or (Flag2  Equals  Yes) = Result2 Result2 And (Flag3 Equals  Yes) = Result3 Result3 And (Flag4 Equals  Yes) = Result4 Result4 Or (Flag5  Equals  Yes) = Filter Result This behavior limits the ways filter conditions can be combined in Microsoft Project. For example, the second member of each pair of possible interpretations above cannot be expressed in a project filter.

If different behavior is needed, a macro using Microsoft Project's Visual Basic for Applications language may be used. Because Visual Basic for Applications has full support of logical expressions, a macro can be used to set a flag field to Yes for those tasks that meet the desired conditions. You can then use a normal Microsoft Project filter that filters the flag field to display the desired tasks.

Additional query words: Logic Complex Long

Keywords: kbprb kbusage KB132462

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.