Notion Rollup Puzzle

Notion Rollup Puzzle
10 Sep, 2021 βΈ±
Sep 10, 2021
Feature on homepage
Here's a Notion rollup puzzle posted by @PhDNotion on Twitter recently, and I learned about it from @Jill.
Let's say we have two cross-linked databases β€” we'll call them genres and books. We frequently add to the books database, and when I add a new entry with a title and a genre (or even a bunch of genres), and open up the entry to add some notes, I'd like to see a gallery view of all books that are in the database so far that share the same genre. So in particular, if I add a book that belongs to genres X and Y, I'd like to see all books who are in genres X or Y (non-exclusive; in the sense that these books may belong to other genres too).
One could do this by creating a linked database with the right view and setting up the filter manually. The question is if this can be automated with a template.
Now, it seems like self-referential filtering with templates should be relevant here. These filters can be applied to any property, but when it comes to the filtering condition, i.e, the value of what the property should match β€” here is where we have the opportunity to make a self-reference, but unfortunately this reference can only be made to the title of the entry we are working with.
notion image
Now we are working with the database of books, and being able to only filter by title isn't useful β€” yet! But we can get to what we want by adding a rollup field to the books database which pulls up all books that share the genre of the current book (just make sure that the rollup field is configured to pull up entries from the relational genres column):
notion image
Now you can set your self-referential filter like so:
notion image
Now let's look at what happens when we add a new book with information about genre:
Tada! πŸŽ‰ This solution was inspired by a suggestion of @TomFrankly in this tweet:
and there's a video too if you would like to take a look at this in a more elaborate context: