Let the platform do the work

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.

rest/v11/doc_PagesFiles/b1902105-3312-d8a1-86c9-550282d8dbff/file/uploadfile?force_download=0&platform=base

In order to only return records in Springfield OH, you would have to create a filter for Billing City = Springfield AND Billing State = OH.

rest/v11/doc_PagesFiles/e8aac443-d8f5-8a2e-684f-550282b893a3/file/uploadfile?force_download=0&platform=base

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.

rest/v11/doc_PagesFiles/2c4c198c-0028-7d77-1957-550282d0d3ab/file/uploadfile?force_download=0&platform=base

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.

rest/v11/doc_PagesFiles/6abd3f6f-79a8-bae9-51d6-550282810b39/file/uploadfile?force_download=0&platform=base

In order to see both records, you will have to use an OR operator.

rest/v11/doc_PagesFiles/a33f0ed6-c6ff-e452-53a0-550282029c28/file/uploadfile?force_download=0&platform=base

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".

rest/v11/doc_PagesFiles/d86b3fb8-cf98-13dc-7f1f-550282921526/file/uploadfile?force_download=0&platform=base