In Power Searching it is important to understand how to correctly combine statements.
As a general rule we need to make sure that complex AND statements are handled as a one line query.
The best way to explain why is to illustrate with the following examples.
Contact A |
Contact B |
Contact C |
Contact D |
$10 S2 |
$10,000 S1 |
$5 S1 |
$5 S1 |
$200 S1 |
$15,000 S2 |
|
$50 S2 |
$10 S1 |
|
|
$200 S2 |
In the above table we have four contacts that have made donations to various source codes (S1 or S2). We want to find contacts that have donations in the range between $10 and $300 for source code S1.
The rationale behind setting up statements for this search is to set up one statement or to set up a number of separate statements connected by AND
By using a SINGLE statement (which is the correct statement) where the criteria are combined into one line as follows:
Donation amount >= 10 AND Donation amount <= 300 AND source code=S1
thankQ evaluates this one statement and returns the contact records that have donations that meet all three parts of this search.
In this case the only contact record that applies is Contact A.
In terms of power searching, when we use the AND function to join statements together the above method is the correct approach to choose.
You may also have considered the following statement:
Donation amount >= 10 AND Donation amount <= 300 AND Source code = S1 |
In this case, thankQ evaluates each of these statements separately and combines the results to return the matching contact records. Taking each statement:
Donation amount >= 10 |
A, B, D |
AND Donation amount <= 300 |
A, C, D |
AND Source code = S1 |
A, B, C, D |
thankQ now selects the records that are common to all statements and returns those as the search results.
In this case, contacts A and D match all of the search criteria.
If we look at our original search criteria, we wanted to find contacts that had made a donation to source code S1 of between $10 and $300.
Looking at Contact D’s transaction it appears that he does not fit the criteria and should not have been returned in the results. However, following the logic described above you can see why his record was selected.
The following example illustrates the above approach
Example:
I want to find contacts who have made donations between 100 and 1000 in the period 1/1/06 to 31/12/06 where the source type is Appeal.
Using a single line statement from the Donations Folder as follows is the correct approach
SINGLE DONATION less than or equal to ? and greater than or equal to ? between START DATE ? and END DATE ? for SOURCE TYPE of ?
Use a statement that combines the criteria into one line. Note that the count is 90 contacts.
It is also tempting to construct this statement as follows.
DO NOT construct an AND statement joining the various criteria as above. This will result in a different and incorrect result with a count. In this example 158 contacts as opposed to 90 with a single line search.
thankQ evaluates each of these statements separately and combines the results to return the matching contact records