# Bring in data from the table into a new row

I have setup a new row button, with a formula to add the current date.

I would like to also bring in the one cell from the prior row.

For example, when setting goals for a day, a new row signals a new day, it would be great to bring in the previous days goal into the new row

thanks!

1 Like

Not sure I understand well yor point, but trying this : you want to add new row for a new day, and that stuff in the previous row are copied in the new one, right ?

If yes, try configuring your button this way, and the date as well as showed >

Button configuration

Date Configuration*

Live Action : The text of â€śTaskâ€ť Column is copied to the next day

4 Likes

HI Andy,

In Coda the term prior row can be determined in three different ways.

Creation Order.
There is a field called RowId that is created when a new row is added. This is a sequential number, and the number can never be re-used. â€śPrior Rowâ€ť in this case would then be the row created just before.

Table order
You can create row One and Row Three, and then insert Row Two afterwards between One and Three. In table order, your rows would then be One, Two, Three, but in Create Order the sequence would be One, Three, Two.

Sort Order
Tables can be sorted in any number of ways, and â€śPrior Rowâ€ť in a sorted view would then depend on the sort rule for that view.

Because of the above, @Quentin_Morel 's suggestion to use the date is very good. People tend to create an index in docs where they want to refer to a â€śprior rowâ€ť.

And I just thought of something as well - The problem with RowId is that when rows are deleted, that number is missing, and formulas that rely on, say, the RowId-1 to get the previous row, could look for a non-existing record. But the Creation Date for the row will still be in sequence. You could probably use a combination of the find() and nth() formulas to find the prior row. In creation sequence.

Regards
Rambling Pete

2 Likes

About that indeed, I wrote something I would not use my self, I thought about that after posting and told myself I needed to come back here to correct ! Youâ€™re faster than me !

In pratice, it was an example of how to autofill date, but indeed this is not stable, and there are many ways to create this id-like. Probably the best idea would be to use daily automation that would trigger the button, and add to the button the adding of the current date when itâ€™s triggering. May be OP would like to manually push the button each day, I donâ€™t know.
But for the main point, I fully agree with you to the fact that in the main use case, we cannot use RowId as relevant tracker !

2 Likes

for the date I am using a very simple function to add the date when I request the new rowâ€¦this is an action I want to take.

For adding the previous days tasks, @Quentin_Morel, your example is perfect, that is exaclty what I am trying to create.

to @Piet_Strydom suggestion, date would be perfect.

2 questions;

1. what would the formula be using date?
2. where do i enter the formula, in the button settings or in the cell?

1 Like

I would create the column `CreatedOn()` that will be filled automatically, and a column to rank your row according to the CreatedOn column, something like `Rank(thisRow.[Created on],thisTable.[Created on],True() )`

That should replace the RowId, without missing anything

Quentin

3 Likes

Yeah, that what I had in mind

2 Likes

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