Skip to main content
Conga Support

Auto-generated Content Data-Group-By Attribute

data-group-by

data-group-by allows you to show roll-up summary information of a group of records.

Syntax: data-group-by="field_name"
Aggregator functions are used to access the summary data of the records grouped by data-group-by

[SUM(field_name)] - sums value of field_name in each record in a group
[COUNT(field_name)] - counts the number of field_name entries in a group

Example Use Case: Sum total price of OpportunityLineItems records by Product Family

In the example use case above, if we don’t use data-group-by, the SUM function will display the sum of all products together.  Consider the table below, where the Total Price for Apple is $1, the Total Price for Carrot is $2, and the Total Price for Pear is $3.

Output:

Without data-group-by:

Product Name Product Family Total Price
Apple Fruit $6
Carrot Vegetable $6
Pear Fruit $6

Because there is no data-group-by attribute, the SUM function displays the total sum of all the products and does not split out based on Product Family.  In addition, because the result of the SUM function gets treated as a value associated with each product in the array, it gets repeated for every product in the table. The HTML can be seen below.

HTML:

<table data-source="OpportunityLineItems">
   <thead>
      <tr>
         <th>Product Name</th>
         <th>Product Family</th>
         <th>Total Price</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>[PricebookEntry.Product2.Name]</td>
         <td>[PricebookEntry.Product2.Family]</td
         <td>[SUM(TotalPrice)]</td>
      </tr>
   </tbody>
</table>

Adding the data-group-by attribute solves this problem by telling Conga Collaborate to only sum products that have the same Product Family.  This also keeps the summed total from being displayed more than once.

A quick note: We have removed the Product Name column from the table below because data-group-by does what its name implies - it groups the entries and only makes one table entry per group.  The Product Family Fruit (which can be thought of as a group) has two products associated with it, so normally there would be two entries in the table.  However, because we are using data-group-by and grouping by Product Family, there will be only one entry in the table for the Product Family Fruit.  Therefore there will only be one Product Name entry (and missing the other), so we remove it from the table.

With data-group-by:

Product Family Total Price
Fruit $4
Vegetable $2

HTML:

<table data-source="OpportunityLineItems">
   <thead>
      <tr>
         <th>Product Family</th>
         <th>Total Price</th>
      </tr>
   </thead>
   <tbody>
      <tr data-group-by="PricebookEntry.Product2.Family">
         <td>[PricebookEntry.Product2.Family]</td>
         <td>[SUM(TotalPrice)]</td>
      </tr>
   </tbody>
</table>
  • Was this article helpful?