Formula Map - Refer to the NextValue after CurrentValue

I have a multiple list of dates, where in number of elements are varied.


[September 1, 2010, July 1, 2016, July 1, 2022]
[September 1, 2010, July 1, 2016, July 1, 2022, September 2, 2023]
[September 1, 2010, July 1, 2016, July 1, 2022, September 2, 2023, January 1, 2025]

I want to use FormulaMap to subtract the years

2nd date - 1st date, 3rd date - 2nd date, 4th date - 3rd date, 5th date - 4th date

thisRow.[List of Effective Dates].FormulaMap( CurrentValue)

How will I refer to the next value of the currentvalue of the list ? Or is there any other way to do it (like loop) ?



in this case we would create an ‘index’ value, i, that goes from 2 to N, where N is the number of items in the list you are processing.

so inside the loop you can write

Items.Nth(i) - Items.Nth(i - 1)

we do this using the Sequence() function to create the list 2, 3, 4, … N

and then use the FormulaMap() function on THAT list

we then use the WithName() function to assign the name “i” to CurrentValue, making it easier to use in your formula

resulting in the following formula…

Sequence(2, Items.Count() )
      Items.Nth(i) - Items.Nth(i - 1)



Great, thank you so much!

For future visitors to this thread, if you are looking for some techniques to reference “PreviousRow” or “NextRow”, check out this oldie-but-goodie thread:

1 Like

Great reminder @Ryan_Martens2 ,

These detailed write ups from Shishir are very valuable and key when you want to learn the hidden gems in Coda being able to make YOUR doc functional solution as an app.

1 Like

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