Summing up an airtable field

@NigelG @pford If you can’t use the Sum function in Adalo, you can do it in Airtable.

You need linked tables and the Rollup function in Airtable.
Let’s start with an simple example:
image

If I want to sum the Amount of all records, I can build a linked table like this:

  1. Add a new field Link of type Formula. Fill the formula with a unique string, such as “.”
    image
    Result:
    image
  2. Change the field type from Formula to Link to another record:
    Click the dropdown arrow of the field header and select Customize field type
    image
    Select Link to another record
    image
    Select Create a new Table
    image
    Enter the name of the new Table (“Calculations”) and click Save.
    Click Skip adding additional fields. (You can do this later, if you need to, but it’s not relevant for the calculation).

    Result:
    The field type changed and you created a new table.
    image
    The new table contains just one record.
    image
  3. For the calculation, add a new field of type Rollup:
    image
    Enter a Name and select the type Rollup.
    For the Rollup details select the linked table and the field you want to calculate (“Amount”).
    For the Aggregation choose SUM(values) and click Save.
    Result:
    image
    The Total is now automatically calculated whenever there is a change in the linked table.

A more complex scenario
In this scenario I am using several tables linked to each other:
A Customer table:


The Customer table links to the Orders

Orders link to Order Items

Order Items link to Products

Beside the base price In the Product table that is used for the multiplication with the ordered quantity, the table also contains an example for using aggregation in rollup field:

The field Ordered Quantity Total calculates the sum of all quantities ordered:

To show the difference I also added a Lookup field with multiple values:
image

image

Filtering linked tables in Adalo
Using linked tables in Airtable is somehow tricky when it comes to filtering in Adalo.
Important to know is that a linked record in Airtable is displayed with the key (= first column of the table).
image.
Technically it is handled as an array like [id,key] where key is the first column of the table, in my example the autogenerated Index number.

BUT
In Adalo you cannot use the key or the array, because Adalo cannot handle the array.
So what to do when you want to filter the Orders by customers, or the Order Items by customers or product.

Here comes the trick
You need to duplicate the key using a simple fromula field in Airtable.
In the Order table example we have the Customer linked by the index number (=customer number) of the Customer table.
image

  1. Add an additional field of type Formula.
    image
    Result:
    we now have the key in a separate field that can be used for filtering in Adalo.
    image
  2. Repeat the same for all linked values you need for filtering in Adalo.

For example in the Customer table


image
3. If you need to work with multiple linked entries like in the Order field in (a customer has multiple orders linked) use the following formula to create a separate field you can search in Adalo:
image

In Adalo you need to use Search in the filterByFormula value, e.g. Search(‘string’,{airtable_field}).

  1. Don’t forget to update the changed Airtable structure in Adalo by clicking through the setup steps.

Filtering in Adalo using the additional fields
When I want to see the orders of a selected customer the filter for airtable looks like this:

For more details see also: How do I automatically add up all values in a colu... - Airtable Community and Multi-record calculations (c.f. 'running balance,'... - Airtable Community

@NigelG ARE YOU STILL WITH ME :slight_smile:

If this is helpful and you think this qualifies for your $200 offer, please send the money to the charity organization my wife is running in Sudan:

Click on Donations to find the relevant information.
If you are in the US and scarred to do a banking transaction with Sudan, please DM me :slight_smile: