Button to copy set of rows to new month

Note: this topic resembles an answered post, but is quite different in that previous topics discuss copying per-row, rather than multiple rows at once.

the problem: using a button to “duplicate rows” allows you to enter new values for the various columns in the new rows, but how do you say “value (of new row) = existing value (of copied row) + 1”?

i have created a very basic table with the latest stab at a solution using a FormulaMap but that doesn’t work.

even if i could do:
RunActions(
duplicateRows(…rows are duplicated, pending column is true)
ModifyRows (modify rows where pending = true, such that ThisMonth.date = NextMonth.date) //these are fudged cols, commands, but you might get where i’m going with that. it still complains that i can’t set a date field to a column/set of dates
)
any help is appreciated. i’ve been working on this for far too long!

Hello, I propose a solution on your doc.
I have unstructured the steps.

→ one button per row to perform the duplicate action and +1month

→ a checkbox to indicate where the button will be activated (dynamic formula)
the checkbox is not based on the nextDate column.
It retrieves the row with the same name and the latest date and compares it with the current row.

→ a general button to retrieve the rows with the true checkbox and click on the buttons.

Math

2 Likes

wow, thank you!

am i the only one that thinks this is a little complex to simply change the values of duplicated rows from their current value to a consistently updated value (in this case from one month to the next)?

sigh. #codalife

no you are not the only one, but this is not complex, it is maybe difficult at first, but that means you can acquire the skills required to produce a comparable outcome. @Math_24 did a great job in showing a possible route to the end point.

Complex is different, in that scenario you don’t see the wood for the trees and in general complexity is a bad omen, it obscures often that the mind of the maker was not clear :wink:

Simply enjoy the great gift of @Math_24 !

1 Like

ok, you’re right, it isn’t “complex,” per se, and my previous response didn’t represent the gratitude i feel toward @Math_24 and this community for the help that was so graciously provided.
i guess what i’m frustrated with is that it seems like this simple problem, requires a change to the the table in order to get a solution. if you have to change your data in order for your logic to work, something is wrong with your tool. perhaps there is a solution to this problem that doesn’t require new columns to the table, but as of yet, i haven’t seen anything that would be less than 6 lines of code. 6+ lines of code to do something as simple as [RowName].thisRow.[ColumnName]+1 – but nothing like that exists, and this community seems to be ok with that, i guess.
which makes me the a$$hole, i get it. i do.
in my search for answers i see so many convoluted solutions for problems that are, relatively, basic.
if i’m copying rows within a table, i would expect have access to the data in those rows without needing to create new columns in the table, no?
you’re right, though, i do need to understand things in Coda better - i don’t understand why i don’t have access to anything like thisRow or CurrentValue when trying to assign a value to the new rows in a formulaic or sequential manner. we have to do formulaic gymnastics to get access to data that common-sensically will be needed.
if i’m duplicating a set of rows, it isn’t a stretch to thing think i’d want to access or modify the data contained therein.
i feel bad even asking for help, for something so basic, but seeing @math_24’s solution helps me realize i was looking for something that doesn’t exist. and i appreciate his ingenuity and the time he took to come up with it and share it with me.
so, i’m saying two things: thank you to the community for being helpful and awesome - it has saved me more times than i can count, and thank you especially to @Math_24
and…an expression of frustration. i’ve been a pro user of Coda for nearly 4 years now, and i still ask myself, “is this a table I should just build in excel?” and i really hate asking myself that question - because i love so many things about the product and the pricing - but when when something so basic as the ability to Duplicate Rows is supported with zero straightforward methods by which the data within those rows can be accessed and modified, i’ve got to think that my use cases for the app are simply outside of the roadmap. just…venting to a group i suspect could be sympathetic to the plight.

2 Likes

I think much of the confusion stems from the fact that previous-row and next-row in Coda are very different topics than what they are in Excel.

In Excel, what you see is what you get. In Coda, the context is all important, and can be different in different views. Typically the basic table is in “creation date sequence”. But you can manipulate the table in such a way that the “table order sequence” is different. And you can also expressly sort the table, ascending or descending, in another view.

Now it is clear that previous-row means different things in different views. In the same way thisrow + 1 is also meaningless without context.

Once one understands this underlying concept what seemed to be complex, becomes simple.

It’s just a ramble,
Rambling Pete.

1 Like

Thanks, @Piet_Strydom

the more i learn of Coda, the more i realize i don’t know.

i think i’ve muddled this discussion a bit. and my example wasn’t very good.

my use case is an expenses table. and i’m trying to duplicated the rows for one moth to the next month using a button. (see Expenses Take 2)

the beauty of this tool is that the button has almost everything i need. it makes it so simple.
except that i want the Date field for the copied rows to advance by one month.
i can select my to-be-copied dataset nicely - the filter works great. i can even create a FormulaMap and modify the dates in the copied dataset to the next month - but i can’t seem to figure out how to put them back into the fields one-at-a-time.
is there a method within the context of duplicating a set of rows to iterate the copied set, read the value of a column for each row, and modify that value?

ok, so the real problem is i don’t know how to modify a set of dates from, say, a button.

i would think something like this would work, but it show i don’t have thisRow:
image

that’s where i’m getting stuck.

(i put that formula in Expenses Take 3:
https://coda.io/d/Copy-Dates-to-New-Month-Test_d2SoPk3Wnxr/Expenses-Take-3_suWeu?utm_campaign=embed&utm_medium=web&utm_source=2SoPk3Wnxr#_luj1k )

hi @Dallas_Browning ,

this is my contribution to your puzzle:

[DB Expenses].ForEach([Expenses 2].
  AddRow(
    [Expenses 2].Name,CurrentValue,
    [Expenses 2].dueDate,CurrentValue.dueDate.RelativeDate(1),
    [Expenses 2].Amount,CurrentValue.Amount)
    
  )

and maybe the relatative date thing should be Today().RelativatDate(1) and the button only should be active in the new month, etc.

I do understand that what looks obvious is not, I hope this helps a bit, cheers!

Yes, no problem :wink: . I understand you want to duplicate the row. But it is possible to modify the row and add a month.

For your recurring expanse, you can use automation to duplicate them at the beginning of each month.
with the same principle as above


For you button dupplicate, Expense 2 :
You can name the buton and active 1first by month for duplicate with automation.

i build 2 button for example :
image

First btn example :

Second btn example :

2 Likes

thank you! thank you!

so i currently have a button that marks the items in the current month as pending, and another button, using the code you added to copy just those items.
i suspect i could avoid that first step and, instead create a filter that selects just the items for this month and then uses the AddRow to “copy” them to next month.

regardless, thank you @Math_24 and @Christiaan_Huizer - i’m still a little fuzzy as to when CurrentValue and ThisRow are available to me, but your logic and reason is clear and is helping me understand.

thanks again!

this one may help you, I do understand that it is not easy, once you accept that, you start learning. I am sure that also @Math_24 needed time to acquire his current understanding, like I did. It is doable, just practice :wink:

Cheers!

1 Like

Sweet! I’ll read it! and keep practicing.

in the end, this is the formula i used for the button, using what you guys sent me:

([Expenses 2].Filter(dueDate.DateTimeTruncate("month")= Today().DateTimeTruncate("month"))).ForEach(
[Expenses 2].AddRow(
    [Expenses 2].Name,CurrentValue,
    [Expenses 2].dueDate,CurrentValue.dueDate.RelativeDate(1) ,
    [Expenses 2].Amount,CurrentValue.Amount )
    
  )

this filters the list down to the rows for this month, and for each row, adds a new row with the next-month’s date.
thanks again!

//Dallas

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