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.
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):
Now you can set your self-referential filter like so:
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: