Visual Editors
Formula Builder

Formula Builder

TimberCloud Storefront — Product Catalog

The Formula Builder is a powerful step-based visual editor used throughout TimberCloud for creating calculations without writing code. Build complex formulas by selecting values, operators, and measurements in an intuitive interface.

Overview

The same Formula Builder powers calculations across the platform:

FeatureUse Case
PricingCalculate product prices based on dimensions, materials, and options
PartsDetermine part dimensions and quantities dynamically
InventoryCalculate material deductions when orders are placed
WeightCompute part weights from dimensions and density

Learn it once, use it everywhere.


Getting Started

Accessing the Formula Builder

The builder opens from various locations depending on what you're calculating:

  • Pricing: Product → Pricing → "Open Formula Builder"
  • Parts: Product → Parts → Part dimension or quantity → "Edit Formula"
  • Inventory: Product → Inventory → "Create Formula"
  • Weight: Product → Parts → Weight → "Calculation" mode

Interface Overview

AreaPurpose
Info BoxTips and available operand types
Common FormulasQuick-start templates for your context
Formula PreviewVisual representation of your formula
Formula StepsWhere you build your calculation step by step

Operand Types

Each step in your formula uses one of these operand types:

Field

Reference values from the order or product:

Line Items

  • qty - Quantity ordered
  • width - Item width
  • height - Item height
  • depth - Item depth/thickness
  • length - Item length
  • weight - Item weight

Product Options (Attributes)

  • material.price - Selected material's price
  • material.density - Material density value
  • edge.upcharge - Edge option upcharge
  • finish.name - Selected finish name

Format: attribute_name.property

Number (Static)

Enter fixed numeric values:

  • Constants: 144 for square inch conversion
  • Multipliers: 1.10 for 10% waste factor
  • Base values: 25 for base price
  • Upcharges: 50 for oversized fee

Measurement

Pre-built calculation formulas that automatically handle unit conversions:

MeasurementFormulaCommon Uses
Square Feet(W × H) ÷ 144Panel pricing, sheet goods
Board Feet(T × W × L) ÷ 144Lumber pricing, wood volume
Linear Feetlength ÷ 12Trim, molding, edge banding
Cubic InchesW × H × DVolume calculations
Cubic Feet(W × H × D) ÷ 1728Bulk materials, shipping
Perimeter2 × (W + H)Edge banding length
Waste Factorvalue × (1 + waste%/100)Add waste percentage

When you select a measurement, you configure which fields provide the input values (width, height, thickness, etc.).

Group

Create parentheses for order of operations:

  • Contains its own nested steps
  • Essential for calculations like (A + B) × C
  • Ensures correct mathematical precedence

If/Then/Else (Conditional)

Add logic-based calculations:

  • Condition: Compare a field to a value
  • Then Branch: Value/calculation if condition is true
  • Else Branch: Value/calculation if condition is false

Supports comparison operators:

OperatorSymbolDescription
Greater than>Value is greater
Less than<Value is less
Greater or equal>=Value is greater or equal
Less or equal<=Value is less or equal
Equals=Numeric equality
Not equals!=Not equal
IsisText equality
ContainscontainsText contains

Operators

Connect steps with mathematical operators:

OperatorSymbolDescription
Add+Addition
SubtractSubtraction
Multiply×Multiplication
Divide÷Division

Building Formulas

Step-by-Step Process

  1. Click "Add Step" or start with a template
  2. Select operand type (Field, Number, Measurement, Group, Conditional)
  3. Configure the operand (select field, enter value, or set up measurement)
  4. Add another step if needed
  5. Select operator between steps (+, −, ×, ÷)
  6. Repeat until formula is complete
  7. Review preview to verify formula
  8. Save to apply

Common Formula Templates

Templates vary by context but typically include:

Pricing Templates

  • Price per Square Foot
  • Price per Board Foot
  • Base + Per-unit pricing
  • Tiered quantity pricing

Inventory Templates

  • Quantity Only
  • Board Feet × Quantity
  • Square Feet × Quantity
  • Field × Quantity

Part Dimension Templates

  • Width + Overlay
  • Height minus rail widths
  • Calculated from line item

Formula Examples

Example 1: Pricing - Cabinet Door

Calculate door price based on square feet, material, and edge banding:

Square Feet(width, height) × material.price
+ Perimeter(width, height) × edge.price
+ IF width > 48 THEN 50 ELSE 0

Steps:

  1. Measurement: Square Feet → width, height
  2. Operator: ×
  3. Field: material.price
  4. Operator: +
  5. Measurement: Perimeter → width, height
  6. Operator: ×
  7. Field: edge.price
  8. Operator: +
  9. Conditional: IF width > 48 THEN 50 ELSE 0

Example 2: Inventory - Sheet Goods with Waste

Calculate material deduction including 10% waste:

Square Feet(width, height) × qty × 1.10

Steps:

  1. Measurement: Square Feet → width, height
  2. Operator: ×
  3. Field: qty
  4. Operator: ×
  5. Number: 1.10

Example 3: Part Dimension - Rail Length

Calculate rail length based on door width minus stiles:

width - (stile_width × 2) + lip_factor

Steps:

  1. Field: width
  2. Operator: −
  3. Group:
    • Field: design.stile_width
    • Operator: ×
    • Number: 2
  4. Operator: +
  5. Field: edge.lip_factor

Example 4: Weight - Calculated from Density

Calculate part weight from volume and material density:

Cubic Feet(width, height, depth) × material.density

Steps:

  1. Measurement: Cubic Feet → width, height, depth
  2. Operator: ×
  3. Field: material.density

Example 5: Conditional Pricing - Size Tiers

Different pricing for different sizes:

IF width > 48 THEN
  Square Feet × 35
ELSE IF width > 36 THEN
  Square Feet × 30
ELSE
  Square Feet × 25

Nested conditionals handle multiple tiers.


Advanced Features

Nested Groups

Create complex order of operations:

Formula: (base + material) × (1 + margin)

Group 1: (base_price + material.price)
×
Group 2: (1 + margin_percent)

Nested Conditionals

Handle multiple conditions:

IF qty >= 100 THEN
  price × 0.85
ELSE IF qty >= 50 THEN
  price × 0.90
ELSE IF qty >= 25 THEN
  price × 0.95
ELSE
  price

Combining Measurements

Use multiple measurements in one formula:

Square Feet × price_per_sqft
+ Perimeter × edge_price
+ Cubic Feet × shipping_factor

Formula Preview

The preview displays your formula visually:

Badge ColorMeaning
BlueField references
GreenStatic numbers
PurpleMeasurements
AmberGroups and conditionals
Green circlesOperators (+, −, ×, ÷)

Use the preview to verify your formula structure before saving.


Context-Specific Usage

Pricing Formulas

  • Access from Product → Pricing
  • Result becomes the line item unit price
  • Multiplied by quantity for line total
  • See Pricing for detailed examples

Part Dimension Formulas

  • Access from Product → Parts → Dimension specs
  • Calculate width, length, height, depth
  • Used in build sheets and shipping
  • See Parts for configuration

Part Quantity Formulas

  • Access from Product → Parts → Quantity
  • Determine how many of each part per product
  • Can be static, field-based, or calculated
  • Example: height / 12 for one brace per foot

Part Weight Formulas

  • Access from Product → Parts → Weight
  • Calculate weight from dimensions and density
  • Used for accurate shipping rates
  • Example: Cubic Feet × density

Inventory Formulas

  • Access from Product → Inventory
  • Calculate material deduction on order
  • Supports waste factors and conversions
  • See Inventory Management for details

Legacy Support

If you have existing calculations using the old code editor or visual flow:

  • Legacy formulas continue to work - Backend evaluates them normally
  • Yellow banner indicates legacy configuration is active
  • Creating a new formula overrides the legacy configuration
  • Migration recommended for consistency and easier editing

Best Practices

Keep It Simple

  • Break complex formulas into logical groups
  • Use descriptive field names in attributes
  • Test with known values

Use Templates

  • Start with common formulas when available
  • Modify templates rather than building from scratch
  • Save time on standard calculations

Order of Operations

  • Use Groups (parentheses) to ensure correct order
  • Preview formula to verify structure
  • A + B × C is different from (A + B) × C

Testing

  1. Save the formula
  2. Create a test order with known values
  3. Verify the calculated result
  4. Adjust formula as needed

Troubleshooting

Formula Not Saving

  • Ensure all required inputs are configured
  • Check for empty field selections in measurements
  • Verify the formula has at least one step
  • Look for validation errors in the UI

Wrong Results

  • Check field mappings in measurements
  • Verify operator order (use groups if needed)
  • Test with known values to isolate issues
  • Confirm field names match exactly

Field Not Available

  • Verify the attribute or line item exists on the product
  • Check spelling matches exactly (case-sensitive)
  • Ensure the attribute has the property you're referencing

Legacy Formula Conflicts

  • Look for yellow "Legacy Configuration" banner
  • Create new step-based formula to override
  • Legacy formulas evaluated on backend only

Next Steps