> For the complete documentation index, see [llms.txt](https://university.gonexa.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.gonexa.fr/doc/en/advanced-features/tag-extensions/calculations-sum-count.md).

# Make calculations (SUM, COUNT)

Make a product subtotal or simply count the number of products

{% hint style="danger" %}
**Warning**

Using extensions requires a package version later than 1.7. If needed, update the package through the AppExchange.
{% endhint %}

## Use tag extensions in a table

### Add up amounts with the "SUM" tag

Add up the amounts of the same child object, of a group or even of hidden information, and combine multiple currencies. This way, you avoid formula fields in Salesforce and easily display subtotals.

![Assistant: calculate a sum (SUM)](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/XmqfawJBwGoUYYZN8feW/extensions-balises-1.png)

* After setting up a child object in Salesforce, open the assistant and find the Number tag you want to sum
* Click the "..." at the end of the tag, then "Calculate a sum"
* Copy the suggested tag, which includes the (SUM) tag extension
* Paste it into the table linked to the child object

![Example of SUM subtotals in a table](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/no0x1PcHMxgasZjuRiC6/extensions-balises-2.png)

{% hint style="success" %}
**Example**

Add the Products subtotal and the Services subtotal with one tag in each table: `{!Product|TotalPrice(SUM)}`, `{!Service|TotalPrice(SUM)}`
{% endhint %}

{% hint style="danger" %}
**Warning**

A SUM tag must always be a tag on a child object\
Multi-currency is supported.
{% endhint %}

### Count the number of records in the table

Count the records of the child object to display the number of rows in a table, or the number of records that meet a criterion defined in Salesforce.

![Assistant: Number of records tag](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/shHUqbhKTzHz9SxTSFgQ/extensions-balises-3.png)

* After setting up a child object in Salesforce, open the assistant.
* Go to the tags of the desired child object.
* Scroll to the bottom of the list of available tags and find the "Number of records" tag
* Click it to copy it, and paste it where you want on your page.

{% hint style="danger" %}
**Warning**

A COUNT tag can be displayed inside or outside a table\
A COUNT tag must always be a tag on a child object
{% endhint %}

{% hint style="success" %}
**Example**

Useful to count the number of participants in a training session with the tag `"{!count(Participants)} élèves ont participés à cette formation"`
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://university.gonexa.fr/doc/en/advanced-features/tag-extensions/calculations-sum-count.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
