Button to copy value from one cell to another if conditions are met

Hi!

This might be something totally trivial I’m missing.
I have a row with 2 number columns and a button column.
One number column is input column, the other - let’s call it lowest column - should display the lowest number of the two when the button is clicked. So effectively the button should copy the value from input column to lowest column if lowest column has higher number than input column.

So far I’ve come up with this function, but it’s not copying the right value. The actual row has more columns, and it’s taking the display column value

If(
  thisRow.lowest > thisRow.input,
  thisRow.input,
  thisRow.lowest
)

image

Ideally I wouldn’t even have that button. The lowest column would update whenever input column has value lower than it has.

Any help, please?

May have been a little confused on what you are looking for - but does this solve your problem?

It creates a list from the columns you have inputs in and then pulls out the minimum value with the .min() formula

Thanks for the fast reply! This is almost it - well I thought that would do it, but in my case, it creates a circular reference. I want the Lowest column to be included in the list.

image

Must just be a formula issue, you were on the right track. You can go a step further by hiding the button and letting an automation push it for you (there will be a delay of up to about 20 sec if that’s ok?)

Basically

  • Make a button that copies the price over from input to lowest
  • Disable that button if input >= lowest
  • Attempt to push that button with an automation whenever Input Price is edited (will silently fail if button is disabled, which is what you want anyway)

Yes! thank you. Exactly what I wanted. The automation tip is a nice cherry on top, but I’m on a free tier so it won’t last for long.
I also realized my input (number) column had empty rows but with that red error triangle in the corner. After properly deleting them, everything started working. Maybe empty string leftovers from converting text fields into number fields.

This is basically some bookkeeping for a game :nerd_face:
I tried the same with Notion, but Coda just has better automation and data handling.

Ok great. One last trick is if you can’t use automations, you can also make a button outside the table that pushes all the buttons in a column (so in essence, a single ‘recalculate’ button for the whole table that would sync any rows that need it)

1 Like