# Summing up an airtable field

**URL:** <https://forum.adalo.com/t/summing-up-an-airtable-field/5982>\
**Category:** Get Help\
**Created:** [November 15, 2020, 12:39pm UTC](https://forum.adalo.com/t/summing-up-an-airtable-field/5982 "2020-11-15T12:39:31Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![karimoo](https://avatars.discourse-cdn.com/v4/letter/k/ad7895/32.png) [@karimoo](https://forum.adalo.com/u/karimoo)\
**Post date:** [November 22, 2020, 11:23am UTC](https://forum.adalo.com/t/summing-up-an-airtable-field/5982/12 "2020-11-22T11:23:09Z")

</div>

@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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/c/ca159c148035d9ec9bfde1ce0222cc0e6b02ee5b.png)

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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/1/141aa5bbb4a6e44e3b064e7cc977fb5aca3a2ab4.png)  
**Result:**  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/5/573a6f092bca556a9bd3c3c5a5c7e43bb6f78fe8.png)
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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/1/140c08e1d12e7e7bf43fd1f55492c2e0f5965f43.png)  
Select _Link to another record_  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/b/b6c9d3cb84400133da50e1f88c1564f5278feded.png)  
Select _Create a new Table_  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/fcb9b63b93f9a10193f78da8083e2e4a341b79c3.png)  
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).  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/2/2b6333d60982803160780b075fcefac586353fdd.png)  
**Result:**  
The field type changed and you created a new table.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/9/9708733e1e9a78326dd232b60c85f0371893d950.png)  
The new table contains just one record.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/d/d3e9b77492506dba5c789aeefbb7582132bdf65d.png)
3. For the calculation, add a new field of type Rollup:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/1/1abc168d931123bc4dd6848d65b86ca00bfd7e8c.png)  
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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/b/b2eccd80d78231cb17512f61d2e1796683f978b0.png)  
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:_

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/a/af5c94879ef55b16ce91e2937f80b75af4154b6e.png)  
The _Customer_ table links to the _Orders_  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/e/e4da9ea38f9f461a57183e178b21e8b8c7ac5b33.png)  
_Orders_ link to _Order Items_  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/b/bf61627f54a33bf7d715934b7eb9cb5e6b392c17.png)  
_Order Items_ link to _Products_  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/0/08eea89c5654269002b2f02088ca51444ca46907.png)  
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:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/79e9d8967b05ef6d5dd8c54c115fccdb635c3ca8.png)

To show the difference I also added a _Lookup_ field with multiple values:  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/8/80113604137cf08c7306ec0b4578266cbcb06635.png)

![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/783a1bd56b601df2c284b46712dbebf512dda2f7.png)

**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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/8/8e360a0c4af8cc519de92423a9892525142acb58.png).  
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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/f566a2d428bfc4d94d746401d5808d0d0f1992c6.png)

1. Add an additional field of type _Formula_.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/a/ad0055d595a4f61a37129f349c54e37b8a362064.png)  
**Result:**  
we now have the key in a separate field that can be used for filtering in Adalo.  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/7443cf153bcf1bc5a15ef669f68b075a7286233f.png)
2. Repeat the same for all linked values you need for filtering in Adalo.

For example in the _Customer_ table

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/2/222055447533148865e6009e9fc1f62892af4728.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/f5614247075ebd0aeb8425450e56a546827a7882.png)  
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](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/7/75723c28b64350ac0fab6bdfd00b83616053ec55.png)

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:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/fe79dd99304199a262261c97daeb9c2dee0fd303.png)

For more details see also: [How do I automatically add up all values in a colu... - Airtable Community](https://community.airtable.com/t/how-do-i-automatically-add-up-all-values-in-a-column/2669/4) and [Multi-record calculations (c.f. 'running balance,'... - Airtable Community](https://community.airtable.com/t/multi-record-calculations-c-f-running-balance-row-number-and-the-like/10961)

@NigelG ARE YOU STILL WITH ME 🙂

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:

> **[Drop of Water NGO | قطرة ماء](http://dropofwater-ngo.org)**

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 🙂

---

_[View the full topic](https://forum.adalo.com/t/summing-up-an-airtable-field/5982)._
