Formulas in Layer

Formulas in Layer

Formulas in Layer

Monday, October 6, 2025

Overview

The Formula Field in Layer 4 lets you compute and display values by traversing relationships between categories and operating on those values with a visual, node‑based editor. It unifies quick “relationship lookups” and advanced multi‑step calculations:

  • Pull a single property from a related record (e.g., Vendor → Website)

  • Aggregate related items (e.g., count Model Furniture per product)

  • Deduplicate and group with quantities (e.g., Quantity by Room)

  • Perform multi‑hop lookups across categories and sum costs (e.g., Department furniture cost)

Key idea: When you add a field via Relationships → [Choose a relationship] → [Choose a property], Layer automatically creates a Formula Field with a prefilled formula. You can open and customize that formula in the editor at any time.

Prerequisites

  • You have relevant Relationship Fields configured, such as:

  • You have basic familiarity with editing fields in a category.

Meet the Visual Formula Editor

Open any Formula Field → Field SettingsEdit Formula to launch the editor.

Core parts of the editor:

  • Nodes & Wires: Each node outputs a value (text, number, list, record, etc.). Connect nodes to feed values through the graph.

  • Result node: Connect your final node to Result to output the field value.

  • Preview element: Pick which item to preview so you can see live results as you build.

  • Format panel: Formatting updates based on output type (e.g., text vs number; currency options appear for numeric outputs).

  • Toolbar: Full‑screen, Undo/Redo, Clear Formula.

  • Layout helpers: Zoom all and Auto‑arrange to tidy the graph.

Hover to Inspect: Hover any node to see a live preview of the intermediate value flowing through it (great for debugging).

Quick Start: Pull a Property from a Related Record

Goal: Show the Vendor Website on each Product.

Steps:

  1. In Products, add a new field via Relationships → Vendor → Website. Name it Vendor Website.

  2. Layer creates a Formula Field automatically with the formula like vendor.website.

  3. Open Field Settings → Edit Formula to view or adjust the graph.

  4. Use Preview element to confirm the website on items that have a Vendor.

Tips:

  • If a Product has no Vendor, the result is null. Consider defaulting or formatting as needed.

Example 2: Count Related Model Furniture

Goal: Show how many model furniture instances relate to each Product.

Create the field:

  1. Edit Fields → Add Field → Formula Field. Name it Model Quantity.

  2. Edit Formula and add a node for the Model Furniture relationship.

  3. Add a Count/Length node and connect Model Furniture → Length → Result.

  4. Set Format → Number (e.g., 0 decimals) and Save.

Outcome: Every Product displays a count of related model furniture instances.

Example 3: Quantity by Room (Unique with Quantities)

Goal: List each Room containing the Product’s model furniture, showing how many instances per room.

Create the field:

  1. Add Field → Formula Field. Name it Quantity by Room.

  2. Edit Formula and add Model Furniture.

  3. Drill into Model Furniture → Room (spatial relationship on the furniture items).

  4. Connect the resulting list of Rooms to a Unique node.

  5. In the Format panel for the Unique node, enable Show quantity.

  6. Connect Unique → Result, Save, and Create.

Outcome: The field outputs a list like:

  • Instruction 108 — 15

  • Instruction 106 — 6

Why Unique? The raw list contains one entry per furniture instance. Unique collapses duplicates and—when Show quantity is enabled—reports how many instances exist per room.

Example 4: Multi‑Hop Lookup & Rollup (Department Furniture Cost)

Goal: Sum total furniture cost for each Department, using unit cost from Products and quantities from the model.

Relationship chain (top → down):

  • Department → Rooms (relationship listing rooms in the department)

  • Rooms → Furniture (spatial relationship listing furniture in each room)

  • Furniture → Product (spec link for that instance)

  • Product → Unit Cost (numeric field)

Build the formula:

  1. In Departments, Add Field → Formula Field named Furniture Cost.

  2. Edit Formula and add Rooms.

  3. From Rooms, drill into Furniture.

  4. From Furniture, drill into Product → Unit Cost.

  5. Add a Sum node and connect Unit Cost list → Sum → Result.

  6. Set Format → Number → Currency; select code (e.g., USD) and decimals.

  7. Save and Create.

Outcome: Each Department shows the total estimated furniture cost based on the rooms it includes, the modeled instances in those rooms, and the Product unit costs.

Dynamic updates: Add a new Department (e.g., Shared Spaces), tag its Rooms, and the formula will automatically recompute the total.

Editor Controls & Best Practices

  • Clear Formula to rebuild from scratch when exploring.

  • Undo/Redo liberally while iterating.

  • Use Preview element to validate values on specific items (try several items, especially edge cases with empty relationships).

  • Choose the right format for the Result (Text, Number, Currency) so downstream tables and exports behave correctly.

  • Keep graphs readable with Auto‑arrange; group related steps left‑to‑right.

Troubleshooting

  • Empty results / null values: The previewed item may lack the required relationship (e.g., no Vendor). Pick another Preview element or add guards/defaults.

  • Unexpected counts: Ensure you’re counting the relationship list (not a nested property) and that Unique is enabled only when deduping is desired.

  • Currency formatting missing: The output isn’t a number. Check that a numeric node (e.g., Sum, Count, or math operation) feeds Result.

  • Long lists: Consider summarizing via Count, Unique, or grouping before output.

FAQ

Q: Do I always need to start from Relationships?

A: No. You can create a Formula Field directly and build the node graph from scratch. Selecting a property under Relationships just auto‑generates a formula you can edit later.

Q: Can I reference multiple relationships in one formula?

A: Yes. You can traverse multiple paths (e.g., Vendor and Model Furniture) and combine them with nodes like Concat, Join, Sum, Count, Unique.

Q: Does formatting change the stored value?

A: Formatting affects presentation, not the raw computed value.

Summary

  • Use Formula Fields to compute values across one or more relationships.

  • Start simple (e.g., Vendor → Website) and expand to aggregations (e.g., Model Quantity) and multi‑hop rollups (e.g., Department Furniture Cost).

  • Leverage the visual editor for transparency, live previews, formatting, and organization.

Up Next