Share
Explore

icon picker
First, Last, & Nth

Formulas: First() , Last(), and Nth()
Category: Lists
First().svg
First()
last.svg
Last()
question-mark.svg
Nth()
Provides the first value in a list
Another way to say it...
Provides the last value in a list
Or, as one might say...
Provides the nth value of a list
Said differently...
Hey Coda, can you provide me with the first value from this list?
Hey Coda, can you provide me with the last value from this list?
Hey Coda, here’s a number. Give me the value in that place in the list.

First() and Last() only use one parameter:
ingredients-list.svg
List

First(List)

This is the list that you want to search.

Nth() uses two parameters:
ingredients-list.svg
List

Nth(List, Position)

This is the list in which you want to search for your item.
compass.svg
Position

Nth(List, Position)

This is number of the item in the list that you want to capture.

Manipulating lists will be the bulk of your data-based work in Coda. These three formulas allow you to access a single and specific item within a list.
Lets take this list of random animals for example:
bulleted-list
CattleDogDonkeyGoatHorseRabbitFancy rat varietiesChicken breedsGoose breeds
First()
We can use first() to access the first value in the list

Cattle
is the first value
Last()
We can use Last() to access the last value in the list

Goose breeds
is the last value

Nth()
Nth() is a little more flexible and allows you to access any value in the list including the first or last value. Slide the blue bar below and watch how the list changes. While this formula is a bit more complex, it requires the use of Nth()
Highlight a in the list by adjusting this slider:
0
3
You are accessing the Nth(
3
) value in this list
CattleDog
Donkey
GoatHorseRabbitFancy rat varietiesChicken breedsGoose breeds

idea

Negative Indexes in Coda

In traditional programming languages, you are able to access items in a list using negative indexes. Coda also supports negative indexes in the following four formulas:
Nth, Splice, Slice, Left
Negative indexes will count from the end of a list:
List:
12345
Nth(-1) = 5
Nth(-2) = 4
For more information, see this helpful community post →

Done
Find the 3rd oldest person in a database
Done
Use this lesson’s formulas to pull the information you require from a table
Done

Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.