[Solved] Display Sum (total) of a Airtable column in a label

Hello,
I want to display the total of a column from Airtable. Named Fees… And length of the same Column in another label…
How should I do this?

Thanks😉

1 Like

Hi there,

You can get the Column from Airtable and save it as a list (example from docs). For this let’s say you saved it as a variable called thisList, and that your total is called thisTotal.

To get the total, you want blocks that say
set thisTotal to 0
For each item j in list thisList,
thisTotal = thisTotal + j

Then display thisTotal on a Label.

Is there a chance that the column you get from Airtable will have blank cells in it?

Thanks,
Jane

2 Likes

@jane, Thanks for your Reply :smile:

I didn’t get this code… What’s this code for? (total of list or sum of list?)

No. The column is named : Fees

Thanks :smile:

2 Likes

The first block is to get the sum of the list.
You can find the ‘for each item in list’ block in the ‘Control’ drawer of blocks.

If none of the cells will be empty, then you can use the ‘length of list’ block from the List drawer of blocks to get the length of the list. :grin:

1 Like

Thanks :wink:

2 Likes

Hi,
I tried this code, but not working for me… I want to ADD the values of a column “Today’s Expenditure” and I need to put the sum as the value of another column “Monthwise”. But it is not properly calculating the sum.
After doing this I also need to delete all values from “Today’s Expenditure”, till that date.
Sharing my current code here, request you to help me find the error.

1 Like

You are using the `in list block where is not required. Just use “j”.

Set app variable SUM to app variable SUM + j

[Edit]
Please next time avoid using old posts. This one is 2 years old already

I tried using j, it didn’t work so i tried using in list block…

Sorry, I will avoid using old threads.

1 Like

I’m sure it works but you need to move the create row block inside the then do block to avoid getting 0 in the SUM variable.

I did the mentioned changes, but when i keep it inside then-do, I get NaN as SUM in Monthwise column and if i keep it outside then-do I get 0 as SUM.
I even tried keeping CREATE-ROW inside ELSE, still it is NaN.

1 Like

in this last screen, try to put
01
between “for each… do” and “call Airtable …”
I had this kind of problem working with “for each…”

1 Like

Thank you
I gave WAIT still i am getting NaN as the value… should I convert any value anywhere to any other form.

1 Like

if your values are text, you need to convert to number…
for that, you need to add 0 to any of those values

like: x=x+0 (zero as number in math`s block)

1 Like

NaN means you are trying to add letters to numbers.

Check the content of “j” by displaying it in a label or something to see where you have characters instead of numbers.

Hey, Thank you so much actually the WAIT is working now…

Yes I tried to display j, but it was not displaying as a number, instead something else like [object object etc,
How can i fix it? as j is a for loop variable

Also how can I delete all previous Airtable rows periodically through Thunkable. DELETEROW deletes only a particular ROW

Thank you so much @muneer @mimostel for the tremendous support. With your help I have solved my weeks old issue… Finally its a success…

2 Likes