Sums, Counts, Averages, Min and Max

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.

Adding Filters

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.