MAP
Apply the same calculation to every item in a list.
Use MAP when you have a list of items (prices, names, numbers) and need to transform each one the same way. Common scenarios: adding tax to all prices, formatting customer names consistently, calculating discounts for a product catalog.
How it works
MAP(array, function(argument: transformation))array- The list of items you want to transformfunction(argument: transformation)- A function that defines what to do with each item
The function syntax works like this: you define an argument name, then use it in your transformation formula.
Examples
Add tax to all prices
You have a list of product prices and need to add 21% VAT to each one.
MAP(PRODUCT_PRICES, function(PRICE: PRICE * 1.21))Takes your list of prices and returns a new list with 21% VAT added to each.
Format customer names
Convert all customer names to proper Title Case.
MAP(CUSTOMER_NAMES, function(NAME: TOCAPITALCASE(NAME)))Transforms "john doe" into "John Doe" for every name in the list.
Volume discount per item
Apply 10% discount to any quantity over 100.
MAP(ORDER_QUANTITIES, function(QTY: IF(QTY > 100, QTY * 0.90, QTY)))Checks each quantity and applies the discount only where applicable.
Extract specific data from objects
Pull out just the email addresses from a list of customer objects.
MAP(CUSTOMERS, function(CUSTOMER: CUSTOMER.email))Returns a simple list of email addresses from complex customer data.
Combining MAP with other functions
Calculate total with tax
SUM(MAP(PRICES, function(PRICE: PRICE * 1.21)))Adds tax to all prices, then sums them for a total.
Count items meeting a condition
SUM(MAP(QUANTITIES, function(QTY: IF(QTY > 100, 1, 0))))Counts how many items have quantities over 100.
Transform and filter
FILTER(
MAP(PRODUCTS, function(P: P.price * 1.21)),
function(PRICE: PRICE > 50)
)Adds tax to all products, then filters to only show items over €50.
Common mistakes
Missing function wrapper -
MAP(LIST, PRICE * 1.21)won't work. You needMAP(LIST, function(PRICE: PRICE * 1.21))Thinking MAP changes the original - MAP creates a new list and leaves your original unchanged
Using MAP to filter - If you want to remove items, use FILTER. MAP transforms items but keeps all of them
Complex nested logic - If your function gets too complex, create intermediate variables first
When to use alternatives
Filtering items out: Use FILTER instead
Reducing to single value: Use REDUCE or aggregation functions like SUM, MEAN
Simple operations on all items: Sometimes a direct formula works better than MAP
Related functions
FILTER, REDUCE, SOME, ALL
You can also use MAP with piping syntax for cleaner formulas: PRODUCT_PRICES | MAP(PRICE: PRICE * 1.21)
MAP returns a new list with the same number of items as the original. Each item is transformed according to your function, but nothing is added or removed.