Nithin Bekal Photos About

Obsidian Bases: Formula for star ratings with half stars

14 Nov 2025

I recently started using Obsidian and have been enjoying the Bases feature, which lets you create database-like views using structured notes.

I have a bunch of movie ratings in my notes, and I wanted to display them as stars rather than numbers. The ratings are stored as properties on the notes:

type: [[Movies]]
rating: 4

Now that I have this data, it’s easy to create a view by querying for notes of type: [[Movies]], and adding ratings as one of the properties.

Movie ratings table in Obsidian with numeric ratings

I wanted star ratings to make this easier to read. I came across this article by Tyler Sticka with a formula for star ratings:

'⭐⭐⭐⭐⭐'.slice(0, rating).split('').map(icon('star'))

Here’s how it looks:

Movie ratings table in Obsidian with star icons

This works for whole numbers, but I use half stars in my ratings. Something rated as 4.5 stars will show up as 4 stars. To add half stars, we need to modify the formula to this:

[
  '⭐⭐⭐⭐⭐'.slice(0, rating).split('').map(icon('star')),
  if(number(rating) - number(rating).floor() >= 0.5, icon('star-half'), '')
].flat()

This adds a half star when needed:

Movie ratings table in Obsidian with emoji stars

However, I wasn’t too happy with the appearance of the builtin star icons, and I prefer the use of the emoji ⭐️ for this. This makes the first part of the formula much simpler:

'⭐⭐⭐⭐⭐'.slice(0, rating)

Movie ratings table in Obsidian with numeric ratings

Now, there’s no half star emoji, so I decided to use the ½ character instead, so the final formula looks like:

[
  '⭐⭐⭐⭐⭐'.slice(0, rating),
  if(number(rating) - number(rating).floor() >= 0.5, '½', '')
].flat()

This is what the table finally looks like:

Movie ratings table in Obsidian with numeric ratings

I like how easy it is to customize these tables, and how well these formula functions are documented.

Hi, I’m Nithin! This is my blog about programming. Ruby is my programming language of choice and the topic of most of my articles here, but I occasionally also write about Elixir, and sometimes about the books I read. You can use the atom feed if you wish to subscribe to this blog or follow me on Mastodon.