To ensure that your data is filtered correctly there are certain rules that must be obeyed.
Brackets
Sometimes you may need to build more complex filters for your data. For example, you may want to select Sales Invoice or Sales Credit transactions, but only from accounts with a balance greater than zero.
If you use the following statement:
SLCustomerAccounts.AccountBalance > 0 AND SLPostedCustomerTrans.TransactionTypeShortName LIKE "SI" OR SLPostedCustomerTrans.TransactionTypeShortName LIKE "SC"
when the report is run with the filter applied, an error message appears. This is because the program cannot work out which part of the filter to apply first.
The correct statement to select this information is:
SLCustomerAccounts.AccountBalance > 0 AND (SLPostedCustomerTrans.TransactionTypeShortName LIKE "SI" OR SLPostedCustomerTrans.TransactionTypeShortName LIKE "SC")
The brackets now separate the OR statement from the AND statement.
Reverse Logic
When you are working with negative operators you sometimes need to apply reverse logic.
For example, if you are building a filter on a variable such as Type, where the transaction can only be equal to one type at any time, you could use either OR or AND.
First Statement
SLPostedCustomerTrans.TransactionTypeShortName = "SI" OR
SLPostedCustomerTrans.TransactionTypeShortName = "SC"
Second Statement - using reverse logic
SLPostedCustomerTrans.TransactionTypeShortName <> "OI" AND
SLPostedCustomerTrans.TransactionTypeShortName <> "SR" AND
SLPostedCustomerTrans.TransactionTypeShortName <> "OC" AND
SLPostedCustomerTrans.TransactionTypeShortName <> "SP"
Both filters locates and selects only SI and SC transactions.
NOTE: Brackets are not needed in either of the above filters, unless you add further specifications. If you want to add more to the filter, you should surround both of the above filters with one set of brackets.