Data Management

Using aggregate return type to find the sum

Summary

Hey there! In this guide, we'll show you how to effortlessly calculate the sum of a specific field using Xano's no-code API. This can be super handy for scenarios like calculating the total interest payments from a list of transactions or finding the combined revenue from multiple orders. Let's dive in!

Step 1: Navigate to the Query All Records Function

First things first, head over to the Query All Records function for the data model you want to work with. This function allows you to fetch and manipulate data from your model.

Step 2: Jump to the Output Tab

Once you're in the Query All Records function, click on the Output tab. This is where the magic happens!

Step 3: Set Up the Aggregation

  1. In the Output tab, click on the `return` statement.
  2. Select the `return type aggregate` option.
  3. Click on `add aggregated by` and choose the field you want to sum up (e.g., `interest`).
  4. Give your new field a name, like `sum of interest`.
  5. Under the Aggregator dropdown, select the `sum` option.

Step 4: Save and Run the Query

After making the changes, don't forget to save the query. Then, simply run the function, and voila! You'll see the sum of the specified field displayed in the output.

For example, if you were summing up the `interest` field, and the values in your database were `5`, `10`, `15`, and `115`, the output would show `sum of interest: 145`.

Just like that, you've harnessed the power of Xano's no-code API to calculate sums without writing a single line of code! Pretty neat, right?

This functionality can be a real time-saver, especially when working with large datasets or complex calculations. Give it a try and see how easily you can crunch those numbers with Xano's visual interface.

Happy summing!

This transcript was AI generated to allow users to quickly answer technical questions about Xano.

Was this helpful?

I found it helpful

I need more support
Sign up for XanoSign up for Xano

Build without limits on a secure, scalable backend.

Unblock your team's progress and create a backend that will scale for free.

Start building for free