How to Sum a column from a different table if the date is within the month defined in current table

Hi all,

I’m looking for a formula to Sum a column from a different table if the date is within the month defined in current table. Below is an example doc. I’m trying to sum the “Weight” column from the “Main Table” in the “Month Total” Column of the “Sum If Table” depending on the month in the “Month” column of the “Sum If Table”

Ideally the data appears as described but using a control to define the month would be a runner up option.

Can you update the doc’s sharing permissions to Anyone with the link → Can View (and Advanced → Allow others to copy this doc)

Sorry about that all set!

There are a few ways to do this. Here’s an example that adds a column to the first table for month, which the sumif table then filters based on:

Now, this is going to get a bit messy when you get multiple years involved.

What you may want to do in the SumIf table is have a start date and end date column (Jan 1 - Jan 31). Then your formula in the Harvests column would be MainTable.Filter(StartDate <= HarvestDate AND EndDate >= HarvestDate)

Also note that you don’t need all of these columns I’ve added like Month or Harvests- you can pack a lot of this logic into single formulas. But in general with Coda I would recommend not being afraid to create extra columns as intermediate steps in a process. You can always hide them to reduce clutter, and they give you a good way to visually see the results of each step in the chain when troubleshooting issues, or when going back to some formulas months later and trying to figure out what you were thinking :slight_smile:

2 Likes

Perfect! Thanks a bunch!

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