Understanding AND and OR Operators in Reports
Overview
Understanding the Reports module in Sugar can provide a user with a powerful data analysis tool. One of the more complicated issues surrounding the proper display of information in a report involves understanding which filter operator to use and when. This document will explain the differences between AND/OR operators and provide some examples of how and when each should be used.
Operators
Operators are used in filters to specify which criteria is required to return records in reports. Understanding which operator to use and when is important to return the expected data in your report.
AND
The AND operator allows you to specify one or more conditions that must all match in order to return the record. If any one of the filter conditions do not match a specific record, then that record will not be shown in the report. A good use of the AND condition would be if you wanted to see all Accounts located in a specific City and State. While some cities will be unique to a specific state, there are many cities that are shared across two different states. For example, take the following records:
Name | Billing City | Billing State |
Moe's Bicycle Shop | Springfield | IL |
Mike's Motorcycle Shop | Springfield | OH |
If we create a filter for Billing City = Springfield, then we will get both records from both states.
In order to only return records in Springfield OH, you would have to create a filter for Billing City = Springfield AND Billing State = OH.
Using the AND operator on these two conditions will now reduce my results to only show Account records that have a Billing City = Springfield AND a Billing State = OH.
OR
The OR operator allows you to specify one or more conditions where at least one must match to return the record. If one of the filter conditions does not match a specific record, but the other condition does, then that record will be returned. A good use of the OR condition would be if you wanted to see any Accounts with a designated Industry of "Other" and any Accounts where the designated Type is "Other. For example, take the following records:
Name | Industry | Type |
Moe's Bicycle Shop | Other | Other |
Mike's Motorcycle Shop | Other | Reseller |
If we create an AND filter for Industry = "Other" AND Type = "Other", then we will only see one of the two records.
In order to see both records, you will have to use an OR operator.
Using the OR operator on these two conditions will now change my results to show Account records where Industry = "Other" or any Accounts where Type = "Other".