Counting trip expenses

Feels a bit silly, but on the other hand Excel or programming are overkill for the task. And this way it’s editable on mobile and kept together with other notes about the trip :slight_smile:

The page can have one or more tables, and then I pass a query to a custom function:

**Total cost: {{sum("cost", {table where page =})}}€**
transport: {{sum("cost", {table where page = and tags = 'transport'})}}€

|train ticket #transport|6.25|

The sum function is defined in this Space Script

silverbullet.registerFunction("sum", (key, items) => {
  return items
    .map(i => parseFloat(i[key]))
    .reduce((acc, n) => acc + (isNaN(n) ? 0 : n), 0)

Ah nice use case for the table indexing. Bye bye spreadsheets! :joy:

I love this. Thanks for sharing!
Perfect timing as I am reading this feature while being on vacation and sharing costs.

I have been using for 3 trips so far SilverBullet for cost tracking, though through a simple bullet list. No automatic calculations.

This will save me time.
It would be amazing to enhance it to provide cost-sharing, as I normally create the cost tracking during vacation because I need to share the expenses with other people and at the end of the trip we make numbers.

[UPDATE] I guess I can use tags for it for now :slight_smile:

1 Like

Well, thanks again for doing this.
I just added some more formulas and now I have what I need.

Example with splitting expenses between 2 families (1 of 3 people and the other of 2, so we should pay different amounts at the end of the trip)