Search And Data Processing

Aggregate Two Separate Fields in a Query

Summary

Xano is a powerful no-code platform that allows you to build and deploy backend services for web and mobile applications without writing a single line of code. One of its many capabilities is the ability to aggregate data fields, which can be incredibly useful for data analysis and reporting. However, what if you want to aggregate the sum of two separate fields? Don't worry, Xano has got you covered! In this blog post, we'll walk you through the simple steps to aggregate combined fields using Xano's intuitive interface.

Step 1: Set Up Your Data Table

First things first, you'll need to have a data table with the fields you want to combine and aggregate. For this example, let's assume we have a table called "Sales" with two fields: "Amount One" and "Amount Two."

Step 2: Create an API Endpoint

Next, create an API endpoint that queries all the records from your "Sales" table. In Xano, you can do this by navigating to the "API Endpoints" section and clicking the "+" button to create a new endpoint.

Step 3: Add an Eval Field

Once you have your API endpoint set up, it's time to create an "eval" field that combines the two fields you want to aggregate. Here's how:

  1. In your API endpoint, click on the "Output" tab.
  2. Scroll down and click on the "Evals" section.
  3. Click the "+" button to add a new eval field.
  4. Give your new field a name (e.g., "Combo Amount").
  5. Click on the "Add Filter" button.
  6. Select the "Add" filter type.
  7. For the first value, select your "Amount One" field.
  8. For the second value, select your "Amount Two" field.

Your eval field should now look something like this: `amount_one + amount_two as combo_amount`

Step 4: Aggregate the Combined Field

With your new "Combo Amount" field created, you can now aggregate it just like any other field:

  1. In the "Output" tab, change the "Return Type" to "Aggregate."
  2. Click the "+" button under the "Output" section.
  3. Select your "Combo Amount" field.
  4. Choose the "Sum" aggregator.

Step 5: Run the API Endpoint

That's it! You've successfully set up an API endpoint that aggregates the combined sum of two fields. Run the endpoint, and you should see the total sum of "Amount One" and "Amount Two" displayed in the "Combo Amount" field.

By following these simple steps, you can easily aggregate combined fields in Xano, unlocking powerful data analysis capabilities without writing a single line of code. Whether you're a no-code enthusiast, citizen developer, traditional developer, or part of a startup or small business, Xano makes it easy to build and deploy backend services tailored to your specific needs.

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