Cumulative chart

I have a table, which looks like this:

And a chart powered by it, which looks like this:

However, what I would like is a chart which uses all the same data table, but charts the cumulative value of hours each month, so it looks like this:

I’m guessing I can add a column with a formula, which maybe takes the value for that month and adds it to the value for the previous month, but I’m not quite clever enough to work out how.

Thanks.

(sorry for the combination of links and embedded images, apparently as I new user, there are some limits to what I can do)

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

Is this what you were looking for ? :innocent:
(Look at the green line in the chart called [View of Data] in the sample down below :blush: )

If yes, the formula I used in the Data table (you’ll find below the chart) in the field called [Cumulative Usage Sum] is:

Data.Filter(
  Month <= thisRow.Month
).Usage.Sum()

(Note that Month is in fact CurrentValue.Month)

And what it does is :

  1. It takes the whole list of rows the Data table is and from that whole list of rows (each row in the list being stored as/represented by CurrentValue), I ask Filter() to only keep the rows where CurrentValue.Month is less or equal than the value in thisRow.Month… which returns a filtered list of rows.
  2. From the filtered list of rows, I can then dereference (access) their respective value in the field Usage transforming the list of rows in a list of numbers.
  3. Sum() the values in the list of numbers :blush: .

I hope this helps :innocent: !
Don’t hesitate if this is not what you wanted to accomplish (:sweat_smile: ) … or if you have questions :blush:

Thank you for your help, that’s exactly what I’m looking for. I’m having a bit of trouble making it work in my document:

The value for each field is showing the same value 28.74, which is the total cumulative for all rows - so I think my issue is in the <= filtering.

Can you make your example copyable, please? That way I can see exactly what you’ve done and try and replicate it myself.

Never mind, I’ve figured it out:

(It helps when you read :sweat_smile: )

Thank you so much, this is awesome.

PS, while I have you, is it possible for display multiple types of chart in one? I.e. I’d like the Usage to show as a bar, but for the Allowance to be a line.

I’m glad to know you were able to make it work :raised_hands: !

Coda is pretty smart and interpret a lot of things all by itself but Copy/Pasting can, sometimes, lead to unfortunate errors :innocent: .

If you just deleted the very first Month in the Filter() formula, Coda would have normally suggested you the “right” one (i.e.: the one where CurrentValue.Month is implied :blush: )

And you can always click on a value you use in a formula to get more info about it in the formula editor :blush:
(See the highlighted Month in the screenshot below)

As for this :

It is sadly not natively feasible as Coda doesn’t support combined type of charts at the moment :pensive: .

Maybe there’s a pack in the Gallery that could do it :thinking:, I don’t know (sorry :sweat_smile: )…
Another possibility, a bit complex, would be to look at SVGs … or embed such a chart from GSheets (for example)

1 Like

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