slice

Learn how to use the slice function in Notion formulas.

The slice() function returns a “slice” or specific section of a list as a new list.

slice(list, number, number [optional])

list.slice(number, number [optional])
Code language: JavaScript (javascript)

It accepts three arguments:

  1. The input list.
  2. A starting index, which is included in the output string (the start index of the input string is 0).
  3. An ending index, which is optional and excluded from the output string.
[1, 2, 3, 4, 5].slice(2) /* Output: [3, 4, 5] */

["Luffy", "Sanji", "Nami"].slice(1, 2)
/* Output: ["Sanji"] */
Code language: JavaScript (javascript)

For a more complex example, let’s say you’ve got a list of scores. How could you return the first “streak” of scores, each of which is 100 or higher?

lets(
  scores,
  [32, 56, 22, 9, 104, 155, 123, 3, 10, 145, 33, 42],
  startRemoved,
  scores.slice(
    scores.findIndex(current >= 100)
  ),
  startRemoved.slice(
    0, startRemoved.findIndex(current < 100)
  )
)
Code language: JavaScript (javascript)
About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas