Search

map() | Beginner’s Guide to Notion Formula

post type
notion
formula
tutorial
status
published
author
created time
2024/10/23 12:09
description
Unlock the power of the map() function in Notion formulas to transform lists efficiently! This comprehensive guide will walk you through the structure of map(), how it works, and practical examples, including its integration with the lets() function. Enhance your data manipulation skills and streamline your workflows in Notion by mastering these essential formula features.
cover image
Frame 3.png
1 more property

This is your sign to try map()

map() allows users to apply a specified operation to each item in a list, effectively transforming data in a streamlined way. In this blog post, we will explore the structure of the map() function, breaking down how it works, and providing examples to illustrate its utility.
For this guide, I referenced the Notion Formula documentation and added my own examples and explanations.

Summary

Name
Syntax
Description
Example
map()
map(list, expression) or list.map(expression)
Apply a formula to each item in a list or collection, returning a new list with the transformed items.
map([100, 150, 200], current * 1.1) → [110, 165, 220]

map() Formula

How map() works

The map() function is designed to apply a formula to each item in a list or collection, returning a new list with the transformed items. This is particularly useful for operations where you want to perform the same calculation or modification on multiple elements, enhancing flexibility in data handling.
The syntax for the map() function is as follows:
map(list, expression)
Notion Formula
복사
list.map(expression)
Notion Formula
복사
Breaking it down
List: The collection of items that you want to process.
Expression: This is the expression you want to apply to each item in the list.

Example of map()

Search
example
description
formula
results
Mapping a list containing numbers. - When using the map() function on numbers, it transforms the original list and returns a new list based on the specified expression.
map([100, 150, 200], current * 1.1) - Suppose you have a list of prices for different items and want to add a 10% sales tax to each price. - The original list consists of prices [100, 150, 200]. The expression current * 1.1 adds 10% to each price, resulting in a new list that contains the total prices after tax.
88,165,220.00000000000003
Mapping a list containing pages. - When using the map() function on pages, it transforms the original pages and returns a new list based on the specified expression.
map(prop("Tasks"), current.prop("Date")) - Let’s say there’s a relation property named Tasks containing three items: [Item 1, Item 2, Item 3]. Each item has a date property called Date: - Item 1 with Date Oct 7, 24 - Item 2 with Date Oct 17, 24 - Item 3 with Date Oct 29, 24 The expression current.prop("Created Time") extracts Date of each page and results in a list containing Dates. (Also, notice how this is similar to Rollup!)
,,,,,

Conclusion

The map() function in Notion Formula provides a robust mechanism for transforming lists by applying specified formulas to each item. Experiment with the map() function in your formulas to discover its full potential!
Thank you for reading this tutorial. If you found it helpful, be sure to check out shop for my beautiful templates, which I am confident enough to say are a game-changer Subscribe to my newsletter and feel free to follow me on my social media for updates!
Search