slice
Learn how to use the slice function in Notion formulas.
The slice() function allows you to β€œslice” up a string and output a smaller piece of it.
1
slice(string, number, number [optional])
It accepts three arguments:
  1. 1.
    The input string​
  2. 2.
    A starting index, which is included in the output string (the start index of the input string is 0).
  3. 3.
    An ending index, which is optional and excluded from the output string.
Good to know: slice() works best when you know the indexes you want to use, or when they need to be mathematically derived (e.g. based on a percentage, such as β€œ% of tasks completed”).
If you need to define your index by matching a pattern (e.g. β€œGet the middle name” from a Full Name field), you should use replace or replaceAll instead (or combine them with slice).

1
slice("Dangerfield",0,6) // Output: Danger
2
​
3
slice("Monkey D. Luffy",0,6) // Output: Monkey
4
​
5
slice("Monkey D. Luffy", 10, 15) // Ouput: Luffy
6
​
7
slice("●●●●●●●●●●",0,6) + slice("β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹",0,6) // Output: ●●●●●○○○○○

This example database uses the slice() function to create a simple progress bar. The output of the progress bar is determined by the Percent number property.

slice
College Info Geek on Notion

1
// Compressed
2
slice("●●●●●●●●●●", 0, prop("Percent") * 10) + slice("β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹", 0, (1 - prop("Percent")) * 10) + " " + format(prop("Percent") * 100) + "%"
3
​
4
// Expanded
5
slice(
6
"●●●●●●●●●●",
7
0,
8
prop("Percent") * 10
9
) +
10
slice(
11
"β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹",
12
0,
13
(1 - prop("Percent")) * 10
14
) +
15
" " +
16
format(
17
prop("Percent") * 100
18
) +
19
"%"
This formula creates a progress bar by using two instances of the slice() function, along with the unicode characters ● and β—‹ (see this Unicode character reference for more options).
  1. 1.
    The first slice() starts with ●●●●●●●●●● as the input string. There are 10 ● symbols. We start at index 0, and then define the ending index using the Percent property.
    1. 1.
      Note that we have to multiply prop("Percent") by 10, since a percent value like 40% actually equates to 0.4. Since there are 10 ● characters in our input string, we need an ending index between 0 and 10.
  2. 2.
    The second slice() does nearly the same thing with the string: β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹β—‹, which represents the β€œempty” part of the progress bar.
    1. 1.
      To find the ending index for this string, we use (1 - prop("Percent")) * 10 in order to get the remaining percentage. E.G. if Percent is set to 40% (which would create an end index of 4), we want to set this ending index to 6.
  3. 3.
    Finally, the two strings are concatenated. We also show the actual percentage in the string for good measure.

​
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.
Last modified 21d ago
Copy link
On this page
Example Formulas
Example Database
View and Duplicate Database
β€œProgress” Property Formula