Wanna see something cool? Check out Angular Spotify 🎧

Notion: Rounding to 2 Decimal Places

Notion is an exceptional tool that I have been using for quite some time. Its underlying database structure, which resembles a table, offers customization options with various views such as gallery, board, list, and calendar.

Recently, I created a simple database to track my team’s sprint progress on a weekly basis. The database includes fields for the sprint name, date, number of closed tickets, number of open tickets, and a formula column to automatically calculate the percentage of closed tickets.

The formula is straightforward: closed tickets / (closed tickets + open tickets). In Notion, you can directly reference column names in formulas. For example, I have a formula like "Complete" / ("Complete" + "Open"), which is represented as prop("Complete") / (prop("Complete") + prop("Open")) when copied and pasted.

To visualize the result, I have included screenshots below:

Notion formula column

As you can see, the result is a long decimal number. To round it to two decimal places, we can use a workaround similar to rounding numbers in JavaScript.

Notion formula column

Formula

Here’s the formula to round to two decimal places:

round(prop("Some column") * 100) / 100

You can adjust the number of zeros to round to the desired decimal places. For example, to round to one decimal place, use 10; to round to three decimal places, use 1000.

This is how it appears on the Notion page:

Notion formula column

Why does this work?

Let’s take an example where the result of the formula is 0.531914893617. When you multiply it by 100, it becomes 53.1914893617. Rounding it gives you 53. Finally, dividing it by 100 gives you 0.53.

Here’s the updated result:

Notion formula column

Published 2 Jul 2024

    Read more

     — Adding "loading=lazy" to GIF files on my 7-year-old Gatsby blog (with ChatGPT assistance)
     — Angular v17’s View Transitions: Navigate in Elegance
     — Improving Website Performance with Browser-Level Image Lazy Loading (simply add loading="lazy")
     — Enhancing Cross-Document Navigation with the View Transitions API
     — Upgrading from Angular 15 to 17 in Nx Workspace: A Comprehensive Guide