Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Show Page Sections

download

Advanced Conga Queries

After creating a query with the Conga Query Builder, you may edit the SELECT statement (in the Salesforce record) to add SOQL features that aren't currently available from the Query Builder.

A popular reason to do so is to include one or more of the new SOQL aggregation functions such as SUM( ), COUNT( ), COUNT_DISTINCT(), AVG( ) and GROUP BY which allow you to group and summarize a collection of records.

Once a query has been manually edited, do not use the Query Builder again on that record because the manual edits are overridden. Use Select Count(ID) from the Opportunity

Warning: Due to the complicated nature of SOQL statements, our support staff can only assist with the creation of SOQL statements generated through our tools, such as Conga Query Builder.

Please consult the Salesforce SOQL documentation for complete details about the aggregation functions.

Product Family Example

The following example returns, for each unique Product Family value:

  • The sum of Unit Prices
  • A count of records
  • The average of Unit Price values
    • SELECT PricebookEntry.Product2.Family, SUM(UnitPrice), COUNT(UnitPrice), AVG(UnitPrice)FROM OpportunityLineItemWHERE Opportunity.Id = '{pv0}'GROUP BY PricebookEntry.Product2.Family
For a given Opportunity, this query results in the following values in the Conga ViewDataWorkbook.xls file:


Use Aliases with Aggregate Functions

As displayed above in the Conga ViewDataWorkbook.xls file, the default field names do not clearly identify the source of the values displayed in columns B, C and D. To address this, add to the query a preferred "alias" that will replace the string "EXPRx" and render easily-identifiable field names.

SELECT PricebookEntry.Product2.Family SUM(UnitPrice) MyUnitPrice COUNT(UnitPrice) MyCount AVG(UnitPrice) MyAveragFROM OpportunityLineItemWHERE Opportunity.Id = '{pv0}'GROUP BY PricebookEntry.Product2.Family

For a given Opportunity, this query results in the following values in the Conga ViewDataWorkbook.xls file:


More Powerful Select Statements: Semi-Join and Anti-Join Support

Semi-Joins use the IN (...) operator within a WHERE clause to use the result of one SELECT statement as the search criteria for another SELECT.

Anti-Joins use the NOT IN (…) operator.

  • Example 1:
    • SELECT Id, NameFROM AccountWHERE Id IN(SELECT AccountId FROM Opportunity WHERE StageName = 'Closed Lost')
  • Example 2:
    • SELECT IdFROM AccountWHERE Id NOT IN (SELECT AccountId FROM Opportunity WHERE IsClosed = false)