⚡ Productivity

Notion Formula 2.0 Builder: Database Formulas with lets, ifs, Relation Lists, filter and map, Date Math with dateBetween, Progress Bars, and Styled Status Badges

Write working Notion Formula 2.0 code for a real database: read relation properties as lists, filter and map them instead of building extra rollups, do date math for overdue and due soon logic, build text progress bars and colored status badges with style, and get a test plan for empty and edge cases.

0.0
0Reviews
P
October 6, 2026

Prompt

Act as a Notion workspace consultant who writes Formula 2.0 code for client databases every week, and who knows the syntax changes from the old formula language: relations return lists of pages, current refers to the item inside map and filter, and lets keeps long formulas readable.

Inputs:
- The database name and every property with its exact name and type (checkbox, number, date, status, select, relation, rollup, person): [DatabaseSchema]
- Related databases and the properties on them the formula needs: [RelatedDatabases]
- What each formula should show, in plain words: [FormulaGoals]
- How the result should look (plain number, text, colored badge, emoji bar): [DisplayStyle]
- Edge cases to handle (no related items, empty dates, status values that change): [EdgeCases]
- Output format: [Format]

Generate:
1. A property map: every property the formulas touch, its type, and how it reads in Formula 2.0 (prop("Name") returns a list of pages for a relation, a text value for status and select, a date for date).
2. One formula per item in FormulaGoals, written with lets for intermediate values and ifs for multi branch logic, indented across lines as the Notion editor allows.
3. Relation logic written directly on the list: prop("Tasks").filter(current.prop("Done")).length() style chains, map to pull a number and sum, so the user can delete helper rollups where it makes sense.
4. Date math with today(), dateBetween in the correct argument order (the result is the first date minus the second), and dateAdd, with an explanation of the sign of each result.
5. Display: progress bars with repeat and round, and badges with style(text, "b", color) using Notion's color names, or plain text if DisplayStyle asks for it.
6. Guard clauses for EdgeCases: empty(), division by zero, missing dates, and status names typed exactly as in the schema.
7. A test plan: three or four sample rows with expected outputs to check in the database before rolling the formula out.

Constraints:
- Use only property names from DatabaseSchema and RelatedDatabases; ask about any name that is missing.
- Write Formula 2.0 syntax only, and note any function the user should confirm in the formula editor's built in reference.
- Formulas must not depend on other formulas that create a circular reference. No em dashes.

Instructions

Replace every [bracket] with your details before running. Works on ChatGPT, Claude, and Gemini.

Generated Output

This image was generated using the prompt above.

Notion Formula 2.0 Builder: Database Formulas with lets, ifs, Relation Lists, filter and map, Date Math with dateBetween, Progress Bars, and Styled Status Badges - Result

Examples

Example Input

DatabaseSchema: Projects: Name (title), Status (status: Not started, In progress, Done), Deadline (date), Tasks (relation to Tasks)
RelatedDatabases: Tasks: Name (title), Done (checkbox), Estimate (number, hours), Due (date)
FormulaGoals: (1) progress bar of done tasks, (2) hours of work left, (3) a badge: Complete, X overdue, Due soon if deadline within 7 days, or On track
DisplayStyle: dots for the bar, colored bold badge
EdgeCases: projects with no tasks yet, tasks without a Due date, Deadline empty
Format: formulas with comments, then tests

Example Output

Property map
- prop("Tasks"): list of Task pages
- current.prop("Done"): checkbox inside filter or map
- current.prop("Estimate"): number, may be empty
- current.prop("Due"): date, may be empty
- prop("Status"): text value of the status, compare to "Done" exactly
- prop("Deadline"): date, may be empty

Formula 1: Progress
lets(
  total, prop("Tasks").length(),
  done, prop("Tasks").filter(current.prop("Done")).length(),
  pct, if(total == 0, 0, round(done / total * 100)),
  filled, floor(pct / 10),
  if(total == 0, "No tasks yet",
    repeat("●", filled) + repeat("○", 10 - filled) + " " + format(pct) + "%")
)
The total == 0 guard avoids dividing by zero and shows a clear message instead of an empty bar.

Formula 2: Hours left
prop("Tasks")
  .filter(not current.prop("Done"))
  .map(if(empty(current.prop("Estimate")), 0, current.prop("Estimate")))
  .sum()
Empty estimates count as 0 so the sum never breaks. You can delete an old Hours left rollup once this matches it.

Formula 3: Badge
lets(
  late, prop("Tasks").filter(
    not current.prop("Done") and not empty(current.prop("Due"))
    and dateBetween(today(), current.prop("Due"), "days") > 0
  ).length(),
  daysLeft, if(empty(prop("Deadline")), 999, dateBetween(prop("Deadline"), today(), "days")),
  ifs(
    prop("Status") == "Done", style("Complete", "b", "green"),
    late > 0, style(format(late) + " overdue", "b", "red"),
    daysLeft <= 7, style("Due soon", "b", "orange"),
    style("On track", "b", "gray")
  )
)
Sign notes: dateBetween(today(), Due, "days") is positive when Due is in the past, so > 0 means overdue. dateBetween(Deadline, today(), "days") is positive when the deadline is ahead, so 0 to 7 means due within a week, and a negative number (deadline passed) also shows Due soon unless tasks are overdue. An empty Deadline becomes 999 so it falls through to On track.
Confirm in the editor: style color names and the .sum() method on a list.

Tests
| Project | Setup | Progress | Hours left | Badge |
| A | 4 tasks, 1 done, estimates 2, 3, 1, 4 (done one is 2) | ●●○○○○○○○○ 25% | 8 | On track if no late tasks |
| B | No tasks, Deadline in 3 days | No tasks yet | 0 | Due soon |
| C | 2 open tasks, one Due yesterday, one with no Due | ○ x10 0% | depends on estimates | 1 overdue |
| D | Status Done | any | any | Complete |

Reviews (0)

Please login to leave a review.
Loading reviews...