A newbie trying to understand Button Formulas

Hi @Michael_Bartholomew :blush: !

I’ve created a sample based on your description :blush:. (You’ll find it below)

But first, the explanations :innocent: .

In my sample, this is done with the very first button named Copy_Button.
Its Action formula is this one :

[Example Table].FormulaMap(
  RunActions(
    ModifyRows(
      CurrentValue,
      B,CurrentValue.A
    )
  )
)

And what it does is :

It takes the table [Example Table] and for each row in the table (FormulaMap()) it runs this action (RunActions()) :point_right: ModifyRows() :

  • The row to modify here is represented by CurrentValue
    A table is in fact a list of rows and each row in the list of all rows is stored within CurrentValue. Each very specific value in your column C (for example) is stored as CurrentValue.C which Coda would display as just C in a formula)
  • The column to modify is the column B ( CurrentValue.B)
    In other words, each specific value in the column B
  • The new column value is CurrentValue.A
    I.e.: Each specific value in the “list of all rows” in the column A

Now for the buttons 2 and 3, they work in a similar way as the button 1 does :blush:

It can be done, but you’ll need to set up your Button 3 before the Button 2 in order to use it in the Action formula of the Button 2.

In the Button 3 (named Clear_Button in my sample) the Action formula looks like this :

[Example Table].FormulaMap(
  RunActions(
    ModifyRows(
      CurrentValue,
      B,""
    )
  )
)

Kind of the same as the Button 1 but this time, it acts on B (CurrentValue.B) and replace each specific value in the column B by "" (Blank) :blush: .

And for the Button 2 (named Sum_Button)

RunActions(
[Example Table].FormulaMap(
  RunActions(
    ModifyRows(
      CurrentValue,
      C,C + B
    )
  )
),
Clear_Button)

This one runs 2 distinctive actions :

  1. For each row in your table, it sums each specific value in the column C and each specific value in the column B (and the results appear for each row in the column C)

And then

  1. It pushes the Button 3 (the Clear_Button) :blush:

This is not easy to explain (or to understand for that matter :sweat_smile:)… So, don’t hesitate, if you need more explanations :innocent: .

In the meantime, I hope this helps :innocent: !

PS: Oh and there’s a topic I created a while ago which helped me a lot with FormulaMap() (as I was stuck with this one :innocent: ):

1 Like