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 Prices 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 slick on the chip to customize the number formatting when it is displayed in your app.
![](https://gblobscdn.gitbook.com/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)
You can also had 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.