Billing history total by client ✅ SOLVED

Have a table of clients and a table of billing history. There is more than one bill per client and I want to show the total per-client.

So, which formula should I use to sum each bill filtered by client and show that result in the client´s table? Here´s what I´m trying to achieve:

Billing table example:
BILL 1 – CLIENT “A” – $10
BILL 2 – CLIENT “B” – $15
BILL 3 – CLIENT “A” – $5
BILL 4 – CLIENT “B” – $10

Clients table example:
CLIENT “A” – $15
CLIENT “B” – $25

Thanks in advance!

2 Likes

This is not all that of a noob problem. I get this question all the time!
Take a look at this. Esp. The second option if you already have a clients table.

3 Likes

It took me a while to realise too, absolutely normal because this is a specific way that Coda handles data.
It’s all about using Lookup() and Filter(), often nested within each other. In this case, only use Filter().

Note that I have set the Client column to reference from the Clients Table.

1 Like

Thanks for helping! :raising_hand_man:

Thanks for your time! This worked like a charm. :fist_right: :fist_left:

1 Like

Hello Michael,

Using you filter example: Filter(Billing Table, Client = thisRow).Amount.Sum()
I’d like to see where in my scenario “Client” is date column and “thisRow” is are two date columns - Ranges (ex. StartDt and EndDt columns).

Something like this:
Filter(Date Table, [Dates] >= [Start Dt] < [End Dt]). [Amount].Sum()

Does that make sense?

2 Likes

Hello Michael,

After trying several combinations I found one that worked for me.

Here it is:
Filter([Table 2],Dates.Contains(Sequence(thisRow.[Start Dt],thisRow.[End Dt] ))).Amts.Sum()

Thanks for the post it helped point me to the path.

2 Likes

Hey Edward,

That’s a very inventive use of Sequence, I like it!

Maybe a less recourse intensive way would be:

Filter([Table 2], Dates >= thisRow.[Start Dt] AND Dates < thisRow.[End Dt]).Amts.Sum()

You can use AND like above, or you can also do AND(Dates >= thisRow.[Start Dt], Dates < thisRow.[End Dt])

Thanks Michael,

I’ll give it a try.