includes

Learn how to use the includes function in Notion formulas.

The includes() function returns true if the list in the first argument contains the value specified in the second argument.

includes(list, value)

list.includes(value)
Code language: JavaScript (javascript)
["Luffy", "Sanji", "Nami"].includes("Sanji")

/* Output: true */
Code language: JavaScript (javascript)

You can also combine includes() with functions like map in order to write a test for each element in a list. This test checks if the list contains any odd numbers:

if(
  [2, 4, 6, 8, 9]
    .map(
      current % 2
    )
    .includes(1),
  "List contains at least one odd number.",
  "List contains all even numbers."
)

/* Output: "List contains at least one odd number." */
Code language: JavaScript (javascript)

In my Creator’s Companion template, I include a YouTube Chapters formula that generates a list of timestamps for the video, based off of B-roll items with the “Chapter” meta tag.

Since non-chapter B-roll items can also be related to a content project, I use includes() inside of filter to get only the Chapter items:

prop("B-Roll")
    .filter(
      current.prop("Meta").includes("Chapter")
    )
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