Add a filtered list from one table and sum it up in a column in another table

Hello wonderful Coda community!

I’m creating a budget doc and I can’t figure out what I’m doing wrong in my formula that should give me the total expenses for a particular month.

I have one table with all expenses, and another table where I want to show the sum of all expenses per month.

Here is what I have:

Any help will be greatly appreciated! Thank you!

Hi @Tzviatko_Chiderov and Welcome to the Community :partying_face: !

The formula you’re looking for might be this one :

[Expenses table].Filter(Month = thisRow.Month).Amount.Sum()

(Note that Month is in fact CurrentValue.Month )

And what it does is:

  1. We take the whole list of rows the table [Expenses table] is and we ask Filter() to only keep the rows where the CurrentValue.Month is equal to the value in thisRow.Month.
  2. Then, from the appropriate list of rows returned by Filter(), we can access the value in the field Amount for each row in the list…
  3. And all that’s left, is to Sum() the values in the list :blush:

See the formula in the field Total in the table [Expenses per Month] in the sample below :blush:

Another possibility here would be to use a single select relation field in your table [Expenses table] and use that field to select the appropriate month from your table [Expenses per Month] .

Then, in your table [Expenses per Month] you can easily get back the rows from your table [Expenses table] through a linked relation field … And, from that field, you can easily add a related column to get the appropriate summed up amounts :blush:

I hope this helps :innocent:


Thank you so much for the help, and the quick and detailed explanation @Pch! This works perfectly! Much appreciated!

1 Like

My pleasure @Tzviatko_Chiderov :grin: !

Glad to know this now works as expected :grin: !

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.