Error: A selection can only be created for a query containing an aggregate when the query's primary key field is included in the output.

When attempting to save a selection for a query, the below message appears:

"A selection can only be created for a query containing an aggregate when the query's primary key field is included in the output."

For example, you are under Analysis > Query and have added a new query. On the Set Save Options tab you have checked the box, "Save a selection" and then the error occurs after clicking "Save."
To resolve the issue, add the "Primary key" field to the output of the query results. Below are the lists of Primary keys for common query types:

Queries are added and modified from under Analysis > Information Library > Add/Edit

Constituent Query
On the Browse for fields in: section, highlight Constituents
In the Select Constituents fields: section, add the field "Constituent record" to the Results fields to display: box
On the Set Save Options tab, attempt to save the query and Create a selection again

Revenue Query
On the Browse for fields in: section, highlight Revenue
In the Select Revenue fields: section, add the field "Revenue record" to the Results fields to display: box
On the Set Save Options tab, attempt to save the query and Create a selection again

Sales Orders Query
On the Browse for fields in: section, highlight Sales Orders
In the Select Sales Orders fields: section, add the field "Sales Order record" to the Results fields to display: box
On the Set Save Options tab, attempt to save the query and Create a selection again

Environment

 2.92

Was this article helpful?