Math.js formulas in ZZ allow you to create conditional calculations based on your takeoff properties. This guide will walk you through the basics and provide practical examples.
Important Note: When copying formulas from this guide into ZZ's calculation window, you'll need to retype them rather than copy-paste, as formatting may not carry over properly.
All conditional formulas follow this pattern:
if([Property] condition value, result_if_true, result_if_false)
Let's examine this example: if([Point Count]>=4, 8, 1)
Result: If Point Count is 4 or higher, the formula returns 8. If Point Count is less than 4, it returns 1.
Use these operators to create your conditions:
OperatorMeaningExample>=Greater than or equal to[Height]>=6<=Less than or equal to[Width]<=10>Greater than[Length]>8<Less than[Count]<5==Exactly equal to[Wall Thickness]==8
if([Volume:CY]/[Truck Load CY]>= 10, 0, 1)
What it does: Calculates delivery charges based on truck loads
if([Linear:FT]<8, 1, 0)
What it does: Determines if you need 8-foot boards
(if([Post Height]>=6, 1, 0) + [Number of Clamps per Post]) * [Point Count]
What it does: Adds extra clamps for tall posts
if(and([Linear:FT]>8, [Linear:FT]<=10), 1, 0)
What it does: Checks if length falls within a specific range (greater than 8 AND less than or equal to 10)
if([Point Count]>=4, 8, 1) * ([Volume:CY]/13)
What it does: First determines a base value, then multiplies by another calculation
if([Point Count]<4, [Any Value], [Value of Anything]) + [Point Count]
What it does: Uses different property values as results rather than fixed numbers
You can create dropdown switches in Custom Properties that work like checkboxes:
You now have a custom property that works like checkboxes:
In the Formula Window at the Part with (Calculate Sheathing) Switch, you do not have to make the choice at the item level as this was made at the Takeoff level and it carries down. You just need to create the matching variable in the item.
[Point Count] * [Calculate Post Caps]
What it does:
if([Wall Thickness]==8, 1, 2) * [Linear:FT]/[Length of Product]
Use case: Different material quantities based on wall thickness
((if([Post Height]>=6, 1.[Percentage of Increase], 1) * [Point Count]))/[Production Rate]
Use case: Adjust labor hours based on working height
if([Wall Thickness]==8, 2, 1) * [Linear:FT]/[Length of Product] * [Sill Seal Required?]
Use case: Calculate materials only when needed, with quantity varying by specification
If you're having trouble with a formula:
Much appreciated, Sam.
I asked this question in "Q & A" community, but maybe here is better??? Or is this more of a kb/wiki???