> For the complete documentation index, see [llms.txt](https://help.adalo.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.adalo.com/component-basics/inserting-dynamic-text/connecting-your-database-for-counts-and-aggregating.md).

# Sums, Counts, Averages, Min and Max

This is how you can display sums, counts, averages, min and max with your Adalo app.

*Skill Level: Intermediate to Expert*&#x20;

## Before You Begin

* Should have knowledge of [Databases](https://help.adalo.com/database)&#x20;

## Walkthrough

{% tabs %}
{% tab title="In-Depth" %}
When you have two collections in your database that are related to each other, you can use Magic Text to display Sums, Counts, Averages, Min and Max.

For example, if you have a database collection of Trips and another collection of Activities (and each Activity has a price property) where each Trip can have multiple Activities, if you have a screen or list displaying information about a Trip, you can use Magic Text to display:

* The Count of Activities for that Trip
* The Sum of the Prices for that Trip's Activities
* The Average Price for that Trip's Activities
* The Maximum Price for that Trip's Activities
* The Minimum Price for that Trip's Activities

As with any number, you can click on the chip to [customize the number formatting](/component-basics/inserting-dynamic-text/how-to-format-dates-and-numbers.md) when it is displayed in your app.

![](https://3467607506-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhGHkPsv15svPIU5I7C%2F-LiUVj-CoFOgqcc_6wUX%2F-LiUcAnoFOetqHh45Hh5%2FGif%201%20Count%2C%20Sum%2C%20Ave.%20\(1\).gif?alt=media\&token=0cb40632-b2e6-4f0d-b475-4124f475abcf)

### Adding Filters

You can also add filters to specify which records are included in these aggregations.  For example, if your Activities collection has a True/False property for "Will Definitely Do,"  then you can add a filter so that you're only showing the Sum of the Prices for Activities where "Will Definitely Do" is equal to True.

To add a filter, simply click on the chip, and select Add Filter.

![](https://3467607506-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LhGHkPsv15svPIU5I7C%2F-LmefN2BkLETIPV3BfQM%2F-LmehqCUmbs3F1p1KR5S%2FDemo%20-%20Edited%20\(2\).gif?alt=media\&token=6c0249b0-ce5c-4195-bb7e-36061c7c2532)
{% endtab %}
{% endtabs %}

## Help

If you need additional help with this article, you can always ask in our [community forum](https://forum.adalo.com/)! Be sure to paste the link to this article in your post as well!


---

# 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://help.adalo.com/component-basics/inserting-dynamic-text/connecting-your-database-for-counts-and-aggregating.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.
