Advanced Query Sample
UNDER REVIEW
As an example, we will create a query based on the following question:
"We need to know
how many of our partners that received our March Announcement Letter
have given at least three gifts in the past 6 months that totaled more
than $1000,
or were added to the system in the last three months and have given at
least $100."
Note: Since the sample database is static, we have to make a few adjustments in regards to dates. To illustrate the following sample we will assume that today’s date is 1/1/2010. Generally, queries that are created for continual use will often have the "Adjust over time" check box checked to maintain proper date ranges.
None of the samples in the help section will have this box checked, but in normal use you will often utilize this feature.
Since this request is asking for donors based on a previous mailing, the March Announcement Letter, we will need to create a separate query to retrieve the proper records, and then refer to that query in our new query.
Note: For more information on this, as well as other Special Query Functions, Click Here.
- First we will create a query that finds all the people that received the letter.
- Create a new query, name it XX-March Announcement Recipients (XX represents your initials)
- Choose "Letters" as the Query Type
- Insert "Constituents who received March Announcement Letter" in the description field
- Save the query
- Switch to the Criteria tab, and choose "Appeal ID" under the "Appeals" folder, and drag it to the criteria pane.
- Use the "Is equal to" operator, insert the appeal id (DemoLetter) in the value field
- Switch to the Criteria tab, and choose "Constituent ID" under the "Contacts" folder, and drag it to the output pane
- Click the "Sample Results" icon. The query should return just over 34,000 records.
- Save the query.
Now, we will create the main query.
- Create a new query, and name it "March Letter Analysis"
- Choose "Contacts" as the Query Type
- Insert "March Letter Analysis" in the description field
- Save the Query
- Switch to the Criteria tab, click on the Plus(+) sign next to the "Letters" folder, and drag "With Letters" to the right pane.
- Aegis CRM
will present you with the following dialog box, containing all
of the letter queries in the database.
- Choose the March Announcement Recipients query you created earlier and click "Save".
- Next, expand the "Gifts" folder, and drag "For each gift date" to the right pane, releasing the mouse over the existing criteria. Choose the "Greater than or equal to" operator, and enter 7/1/2009 in the date value field. This action will limit the gifts included to the specific date range.
- Next, under the "Gifts" folder, drag the "Gift Count" field to the right pane, releasing the mouse on the red ampersand. Choose the "Greater than" operator, and enter 2 in the value field
- Next, under the "Gifts" folder, drag the "Sum of Gift Value" field to the right pane, releasing it on the red ampersand. Choose the "Greater than or equal to" operator, and enter a value of $1000.
- Next, under the "Gifts" folder, drag the "Sum of Gift Value" field to the right pane, releasing it on the red ampersand. Choose the "Greater than or equal to" operator, and enter a value of $100.
- Next, under the "Contacts" folder, drag the "Date Joined" field to the right pane, releasing it on the red ampersand. Choose the "Greater than or equal to" operator, and enter 7/1/2009 in the value field.
- Click Save.
- Your
criteria pane should now look like this:
- Aegis CRM
has certain characteristics which allow the user to manipulate
complex criteria. For example, a line item that is dragged
to the red ampersand will automatically be moved to the last entry
in the group. Right-click and hold on "Sum of Gift
Value is Greater than or Equal to 100", and drag and release
it on the red ampersand. Notice that this line has now moved
to the last entry, as below:
- Obviously, at this point for a record to be included in your output, it would have to meet all of the criteria listed. Now is the time to use the "Or" operator.
- 14.
Drag the fourth line ("Sum of Gift Value Is Greater than
or Equal to 1000") onto the line immediately below ("Date
Joined Is Greater than or Equal to 7/1/2009") and release
the mouse. Notice that now a new group has been created
with these two items, identified by a blue "OR".
- Next,
drag the line "Sum of Gift Value Is Greater than or Equal
to 100" onto the first line of the new group ("Date
Joined Is Greater than or Equal to 7/1/2009") and release
the mouse. The criteria pane should now look like this:
- Note
that the Date Joined criteria, and the Sum of Gift Value criteria
has been grouped together under a red ampersand, and the Gift
Count line is alone under the blue "OR" symbol. Hover
your mouse over the first ampersand to view the complete criteria,
which should look like this:
- Save
the query, move to the output tab, and add the following fields:
- Contacts - Partner ID
- Click
the Result Count icon. You should receive approximately
220 records.