Get AI summaries of any video or article — Sign up free
Notion's Slice Function (Formulas Made Easy) thumbnail

Notion's Slice Function (Formulas Made Easy)

Red Gregory·
5 min read

Based on Red Gregory's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Slice extracts substrings from text using start and end character indexes inside Notion formulas.

Briefing

Notion’s Slice function lets users extract specific characters from a text string inside formulas—then convert the result into numbers when needed—unlocking practical workflows like sorting “date-in-title” databases and generating star/progress-style visuals without a dedicated date or numeric field.

A first use case targets a database where each page title encodes a date in a fixed format like “MM-DD-YYYY” (or “month date year”). Instead of using a built-in date property, the setup relies on formulas to slice the year, month, and day out of the title text. Slice works by taking three inputs: the string to read, a start index, and an end index. Indexing is character-based, and spaces count as characters. The transcript emphasizes a common gotcha: when extracting a substring, the start position should be the character *before* the first character you want, and the end position should be the character *you want included* (because the end index is treated as inclusive in practice). Once the year/month/day fragments are sliced, they still come back as strings—so sorting would behave incorrectly unless the values are converted to numbers.

To fix that, the formulas wrap the sliced output in Notion’s two number conversion function (“toNumber” written as two capital N). With year, month, and day extracted and converted, the database can sort properly: first by the year formula, then by month, then by day. After sorting works, the view can hide the intermediate formula properties so the database remains clean, and the layout can be adjusted (for example, switching gallery card settings) to make the “daily pages” view easier to scan.

A second use case turns Slice into a visual rating generator. In a “daily survey” database, each day’s page includes select properties for mood, productivity, and workout, each choosing a value from 1 to 5. The formula builds a star display by slicing a string of five star characters (“★★★★★”) from index 0 up to a computed end index. Changing the end index determines how many stars appear. To make the star count reflect multiple inputs, the end index becomes an average: the formula uses the length function to count how many characters each star value represents (e.g., a 4-star selection corresponds to 4 characters), sums the lengths across the three properties, divides by 3, and then rounds down using floor. For finer control, the transcript suggests scaling by 100, applying floor, then dividing by 100 to keep two-decimal precision before the final floor step.

In short, Slice is the character-level lever: extract from titles or template strings, convert to numbers for correct sorting, and combine with length/average/rounding to create dynamic “progress bar” style outputs inside Notion formulas.

Cornell Notes

Slice in Notion formulas extracts a substring from a text value using start and end character indexes. In a daily-pages database where dates live in the page title (e.g., “MM-DD-YYYY”), slicing the year/month/day and converting the results to numbers (via toNumber) enables correct sorting without a date property. Slice also powers a star-rating display by slicing “★★★★★” up to a computed end index. By using length to count characters for mood/productivity/workout selections, then averaging and rounding down with floor, the formula generates an “overall” star/progress-style rating. This matters because it turns fixed text formats and select values into sortable and visual outputs entirely through formulas.

How does Slice determine which characters to extract in Notion formulas?

Slice takes a string plus a start index and an end index: slice(string, startIndex, endIndex). Indexing is character-based and spaces count as characters. A key practical detail is that the start index should be positioned before the first character you want, and the end index should align with the character you want included—otherwise the extracted substring can drop the first character you expected (like losing the “w” when trying to start at the capital letter).

Why do sliced date fragments need conversion before sorting?

Sliced year/month/day pieces come back as strings even when they look numeric (e.g., “2022”). Strings sort differently than numbers in Notion, so the transcript wraps the sliced result in toNumber (written as two capital N) to ensure numeric sorting. After conversion, sorting by year, then month, then day produces the correct chronological order.

What’s the formula strategy for extracting year, month, and day from a title like “MM-DD-YYYY”?

Use the title property (name) as the string input to Slice, then slice fixed character ranges based on the known format. The transcript slices the year from the appropriate positions near the end of the string, the month from the first two characters, and the day from the middle segment between dashes. Each sliced fragment is then converted to a number with toNumber so the database can sort correctly.

How can Slice generate a star rating display from a template string?

Start with a star template like “★★★★★” and slice it from index 0 up to an end index that represents the rating. If the end index is 3, the slice returns three stars; if it’s 5, it returns five. The transcript replaces the fixed end index with a calculation so the number of stars changes automatically.

How does the transcript compute an overall star rating from mood, productivity, and workout?

It uses length to count characters for each star-based select value (e.g., a 4-star selection corresponds to length 4). It sums length(mood) + length(productivity) + length(workout), divides by 3 to get an average, then wraps the result in floor to round down. For more precise averaging, it suggests scaling by 100, applying floor, then dividing by 100 before the final use in the star-slicing end index.

Review Questions

  1. In Slice, what happens if the start index is placed at the first character you want instead of the character before it?
  2. Why is toNumber necessary after slicing a year or month from a title string?
  3. How do length and floor work together to turn three star selections into a single overall star count?

Key Points

  1. 1

    Slice extracts substrings from text using start and end character indexes inside Notion formulas.

  2. 2

    Character positions are index-based and spaces count as characters, so off-by-one errors can remove the first expected character.

  3. 3

    Sliced numeric-looking text still returns as a string, so sorting requires converting with toNumber.

  4. 4

    For date-in-title databases, slice year/month/day from the title and sort by the resulting numeric formulas to get correct chronological order.

  5. 5

    Slice can build visual outputs by slicing a template string like “★★★★★” up to a computed end index.

  6. 6

    Using length on star-based select values enables averaging across multiple inputs, and floor can round the result down for stable star counts.

Highlights

Slice can turn a fixed-format title like “MM-DD-YYYY” into sortable year/month/day fields—without using a date property.
Sliced results must be converted with toNumber; otherwise, string sorting breaks chronological order.
A star/progress-style formula can be generated by slicing “★★★★★” up to an end index that comes from an average of multiple properties.
The length function provides a simple way to translate star selections into numeric counts for calculations.
floor (optionally combined with scaling) keeps the overall rating within a 1–5 star range and stabilizes rounding.

Topics