Help Center Home
Automation & Workflow: An Introduction to Queries
Authored by: Logan Campbell
on 7/20/2026 2:56:00 AM

Automation & Workflow: An Introduction to Queries

Queries allow you to locate specific records and data in CharityEngine. You can use a query to:

  • Find donors who gave more than a certain amount.
  • Identify sustainers who meet specific criteria.
  • Create an audience for an email or mail campaign.
  • Export records for additional analysis.
  • Support automated jobs, transformations, and triggers.

CharityEngine includes more than 90 out-of-the-box reports and a customizable Report Builder. Use those tools for most reporting needs. Use Queries when you need more advanced filtering, data selection, automation, or campaign audiences.

CharityEngine Query tool overview



Prerequisites

Before creating a query, decide what information you need and how you plan to use it. This will help you select the correct Module, Table, fields, and filters.

  • Start simple. Add only the fields and filters you need.
  • Run the query often. Check the results as you build.
  • Use Reports or Report Builder first when they meet your needs.
  • Use Queries for advanced needs such as complex audiences, automation, or database-level reporting.

Performance note: Queries run against your database in real time. Complex queries, multiple subqueries, and jobs running at the same time may slow performance. A query that takes more than 5–10 minutes is performing a substantial amount of work. A query that takes more than 30 minutes should be reviewed by an experienced administrator.

Related articles:


Understanding Query Structure

Go to Automation > General > Queries > Create New.

A query follows this basic process:

  1. Choose a Module.
  2. Choose a Table.
  3. Add fields to SELECT.
  4. Add criteria to FILTER.
  5. Click RUN to review results.
  6. Save, export, or use the query in another CharityEngine feature.
Area Purpose
SELECT Determines which columns appear in the results.
FILTER Determines which records appear in the results.
RUN Displays a preview of the current results.
SAVE Saves the query and provides additional actions.

Main Query Builder screen


Modules and Tables

A Module is a major area of CharityEngine data, such as Contacts or Donations. A Table is a specific type of information stored within that Module.

Choose a Module

Use the Filter drop-down to choose the Module. For example:

  • Contacts contains contact-related information.
  • Donations contains transaction, sustainer, and invoice information.

Query Module selection

Choose a Table

After selecting a Module, choose a Table using the Select option. The Table determines which fields will be available.

Examples:

  • The Contacts Module includes Tables such as Contacts, Households, and Email.
  • The Donations Module includes Tables such as Transactions, Sustainers, and Invoices.

Contact Query Tables

Donation Query Tables

Click CONTINUE to open the available fields for the selected Table.


Build a Query

Add Fields to SELECT

Expand the field categories or use the search box to locate a field. Drag and drop the field into the SELECT area, or double-click it.

Only add fields you need. Unnecessary fields can slow the query and make the results harder to review.

Selected Query fields

Rename a Selected Field

Click the field label and type a new name. This changes the column heading in the results. Hover over the field to view its original database name.

Renaming a selected Query field

Create a Free-Form Field

Click the + icon in the SELECT area to add a free-form field. Open the field menu and enter the value you want the query to display.

Creating a free-form Query field


Customize Selected Fields

Click the down arrow on a field in the SELECT area to view its available options. Options vary by field type.

  • Set Formula: Apply a calculation such as Average, Count, Sum, or Multiply.
  • Set Value If Blank: Display a default value when the field is empty.
  • Conditional Value: Return a customized value when specified conditions are met.
  • Group By: Group records by the selected field.

Selected field customization options

Removing selected field customizations

Click the applicable icon again to remove a formula, condition, or grouping.


Add Filters

Filters limit which records appear. Filters are optional, but most queries use at least one.

Add a Basic Filter

Drag a field into the FILTER area or double-click it. Select the operator and enter the value.

When you add more than one filter, CharityEngine connects them with AND. Click the condition to change it to OR, AND NOT, or OR NOT.

Create a Nested Filter

Click the + icon at the top of the FILTER area. Drag related filter fields into the new group. Nested filters are helpful when you need combinations of AND and OR logic.

Query Filter area

Use a Filter Formula

Hover to the right of a filter field and click the beaker icon. Choose a formula or dynamic date option from the drop-down. Click the beaker icon again to remove the formula.

Filter formula icon

Dynamic Query filter example

Pro Tip: Click RUN after adding each major filter. This makes it easier to identify which condition changed the results.

Filter Using an Aggregated SELECT Field

You can also filter by a calculated field in the SELECT area. For example, to find donors who gave at least $100 during the last 12 months:

  1. Group the results by Contact.
  2. Apply Sum to the signed transaction amount.
  3. Filter transactions to the last 12 months.
  4. Include confirmed payments and positive accounting revenue.
  5. Hover over the summed amount and click the Filter icon.
  6. Set the summed value to greater than or equal to $100.

Filtering by a summed Query field


Sort and Preview Results

Sort Results

In the upper-right corner of the DATA area, click the down arrow next to RUN. Select the field to sort by, then choose ascending or descending order.

Query sort menu

Query sort direction

Preview Results and Record Count

Click RUN to populate the DATA panel. Switch to Page view to see the total record count at the bottom of the panel.

Query Page view and record count


Save and Use a Query

Click the SAVE drop-down to access available actions. The exact options may vary based on your permissions and the query configuration.

Query Management

  • Clear All: Remove all SELECT and FILTER fields.
  • Create Another One: Start a new query.
  • Change History: Review historical changes.

Exporting and Scheduling

  • Export Data: Export the query results.
  • Schedule Report: Create a Data Job that exports the query now or on a schedule.

Campaign Audiences

  • Email Blast: Start an email blast using the query audience.
  • Mail Initiative: Start a mail initiative using the query audience.
  • Automated Email: Schedule an automated email series.
  • Emailable Audience: Preview emailable records and exclusions such as opt-outs, duplicates, suppressions, blacklisted addresses, and deceased contacts.
  • Mailable Audience: Preview the estimated mailable audience.

Important: A query used for an email campaign must include the CharityEngine Contact ID in the SELECT area.

Automation

  • Trigger: Create a Data Trigger Job.
  • Transformation: Create a Data Transformation Job.

Query Save menu


Export Query Results

Exporting allows you to view, share, or analyze query results outside CharityEngine.

  1. Go to Automation > General > Queries.
  2. Locate the query, open ACTIONS, and select Export.

Export action from Query listing

  1. In the Export Data Wizard, click NEXT to confirm the data source.

Export Data Wizard data source

  1. Accept or update the required Name.
  2. Optionally enter a future Start time and a Description.
  3. Select the File Type. The default is Tab Delimited (Excel).

Export Data Job settings

  1. Open Email Delivery. Select Attachment to attach the file, or leave it unselected to send a link to the Data Job.
  2. Use Attachment Security to password-protect an attached file, when needed.

Export email delivery settings

  1. Configure FTP Settings only when the file will be delivered by FTP.

Export FTP settings

  1. Open Email Notifications.
  2. Enter recipient email addresses separated by commas.
  3. Update the email subject, if needed.
  4. Select Mark Important or Send if No Records, when appropriate.

Export email notification settings

  1. Click NEXT.
  2. Review the confirmation screen and click FINISH.

Export Next button

CharityEngine will send the completed file as an attachment or provide a link to the Data Job, depending on the delivery settings.

Completed export email

Download completed export file


Manage Saved Queries

Go to Automation > General > Queries to view saved queries. The listing screen displays the query type, configuration, activity, creation date, last-run date, status, visibility, and available actions.

Use the Active setting to activate or deactivate a query. Use Visibility to change a query between Shared and Private.

Saved Query listing screen

Quick Actions

Open the ellipsis menu for a saved query. Available actions may include:

  • Preview: View query output.
  • Edit: Modify the query.
  • Make Private: Restrict visibility.
  • Export: Export query results.
  • Schedule Report: Schedule recurring or future exports.
  • Emailable Audience / Mailable Audience: Preview campaign audience eligibility.
  • Email Blast: Start an email blast.
  • Duplicate: Copy the query.
  • Bulk Delete: Start a transformation that deletes associated records.
  • Initiative Setting: Configure settings for an email initiative.
  • Automated Email: Create an automated email schedule.
  • Delete: Delete the query.

Saved Query quick actions


Advanced Query Features

The features below are intended for experienced users. Test advanced queries carefully before using them with campaigns, transformations, triggers, or scheduled jobs.

Subqueries

A subquery identifies a subset of records that is then used as a filter in another query. The queries must share a compatible ID field.

Example: identify contacts who made a transaction greater than $50 last year on the 20th day of a month, then return their contact details.

  1. Create the transaction subquery and include Contact ID in SELECT.

Transaction subquery example

  1. Create a Contact query and add the desired contact fields to SELECT.
  2. Add Contact ID to FILTER and click the database icon to connect an external query.

Connecting a subquery

  1. Search for the saved subquery by name or ID.

Searching for a subquery

  1. Select the subquery.

Selecting a subquery

  1. Confirm the compatible ID field when more than one ID type is available.
  2. Run the query and review the results.

Subquery filter reference

Note: If the external query does not include a compatible selected field, CharityEngine will display an error. The ID used in the main query's filter must also appear in the subquery's SELECT area.

Subquery compatibility error

Query Categories

Go to Configuration > Reporting > Query Categories > Create New. Enter a required name and click SAVE.

Creating a Query Category

Select the category when saving a query. You can then use the Basic Filter on the Query listing screen to locate queries in that category.

Assigning a Query Category

To assign categories in bulk, select the checkboxes beside the applicable queries and use the bulk category action.

Bulk-assigning Query Categories

Scheduling Queries

Schedule a query export when a user or third party needs the same report regularly. This can be useful for recipients who do not have access to CharityEngine.

See Exporting Data: How to Schedule an Export Data Job.

Dynamic Query Tokens

Dynamic tokens can be used in fields or filters to create calculated values and date-based logic.

Token Purpose Parameters Example
[@NOW] Returns the current system date and time. None [@NOW]
[@MONTHNUMBER] Returns the numeric month from a date. Date/time value [@MONTHNUMBER(@NOW)]
[@DAYOFMONTH] Returns the numeric day of the month. Date/time value [@DAYOFMONTH(@NOW)]
[@YEAR] Returns the numeric year. Date/time value [@YEAR(@NOW)]
[@DATEADD] Adds or subtracts time from a date. Interval, amount, date [@DATEADD(month,1,@NOW)]
[@SUBSTRING] Returns part of a text value. Text, starting position, length [@SUBSTRING(#FIELD,1,2)]
[@LENGTH] Returns the length of a text value. Text [@LENGTH(#FIELD)]
[@FIXED_LENGTH_LEADING_ZERO] Converts a number to a fixed length using leading zeros. Number, desired length [@FIXED_LENGTH_LEADING_ZERO(4,4)]
[@RIGHT] Returns characters from the right side of text. Text, number of characters [@RIGHT(#FIELD,2)]
[@FISCAL_YEAR_START] Returns the current fiscal-year start date. None [@FISCAL_YEAR_START]
[@LAST_FISCAL_YEAR_START] Returns the previous fiscal-year start date. None [@LAST_FISCAL_YEAR_START]
[@NEXT_FISCAL_YEAR_START] Returns the next fiscal-year start date. None [@NEXT_FISCAL_YEAR_START]

Examples

Current month and year in MMYY format:
[@FIXED_LENGTH_LEADING_ZERO(@MONTHNUMBER(@NOW),2)][@RIGHT(@YEAR(@NOW),2)]

Month and year from a selected field:
[@FIXED_LENGTH_LEADING_ZERO(@MONTHNUMBER(#FIELD),2)][@RIGHT(@YEAR(#FIELD),2)]

Free-form field using the current date and time:
[@NOW]

Dynamic token in a free-form field

Substring example: Use [@SUBSTRING(#FIELD,1,2)] to return the first two characters from a field.

Substring dynamic token example

Future-date example: Use a Conditional Value on Contact Create Date to return a future date for a trigger or activity.

Future date Conditional Value

Future date output

Filter example: Use [@DAYOFMONTH(@NOW)] to compare a date field with the current day of the month.

Dynamic token in a Query filter

Date-add example: Use [@DATEADD(month,1,@NOW)] to return a date one month from today.

DATEADD dynamic token example


Best Practices and Performance

Build Efficient Queries

  • Use IDs instead of names when possible.
  • Select only the fields you need.
  • Limit the number of subqueries.
  • Avoid creating a subquery from another subquery.
  • Do not repeat the same filter unnecessarily.
  • Run and validate the query as you build it.
  • Review recurring report and campaign criteria at least once a year.
  • Use an Opt-In List instead of a Query when the audience does not need to update in real time.

Common Performance Mistakes

  • Too many layers: Subqueries built from other subqueries create additional database work and may substantially slow performance.
  • Unnecessary SELECT fields: Extra fields require additional processing, especially inside subqueries.
  • Too many subqueries: Each subquery adds another set of database instructions.

Email Campaign Considerations

Campaign audience queries are time-sensitive because the query must run before the message can be sent. An email audience query that runs for more than two hours will time out and the campaign will fail.

Use CharityEngine's built-in email suppression features instead of manually excluding standard suppressions in every query. Contacts who are opted out, deceased, or blacklisted are excluded through system suppression. You may also configure a global suppression query for organization-specific exclusions.

Example: Avoid Repeating Filters

Suppose you need an email audience made up of contacts who:

  • Belong to a specific email list.
  • Have given a certain amount.
  • Attended an event in the last three years.
  • Live in a specified area.

Keep the email-list requirement in the main query and place the donor, event, and geographic requirements in separate subqueries. This avoids repeating the same email-list filter and reduces unnecessary database work.


FAQs and Additional Reading

Q. How do I expand or collapse all fields in the Query Table?
A. Use Click to show all fields or Click to hide all fields.

Show or hide all Query fields

Additional reading:



Related Articles

Powered by Powered By CharityEngine