Define a reusable function

Write a calculation once, give it a name, and use it in any calculated field. When the math changes, you fix it in one place.

TopicUnits & formulas
TypeHow-to
WhoAdminEngineering
PlanEvery plan
Time6 min
Verified11 Nov 2026

View .md

Use a function when the same calculation appears in several fields or tables. A pump catalog, for example, works out hydraulic power in every pump table. As a function, the math lives in one place, each field just says hydraulic_power(flow, head, 1), and a correction to the math updates every record that uses it.

This guide creates that function, then uses it in a calculated field.

Before you start

  • To create a function, you need the Admin role, or Engineering with Confidential visibility. Everyone can open Functions and try one in its calculator.
  • Have the math at hand, with the unit each value is in. Here: power (hp) = flow (gpm) × head (ft) × specific gravity ÷ 3,960.

How the formula handles units

The constant 3,960 only works when flow is in gpm and head in feet. Your fields may store other units, so the formula asks for the units it needs:

  • num(flow, "GPM") gives the flow as a plain number of gpm, whatever unit the field uses.
  • qty(…, "HP") turns the answer back into a power, in hp.

SpecLatch converts each input before the math runs, so a flow stored in m³/h works as well as one in gpm.

Create the function

  1. In the sidebar, open Functions and click New function.
  2. Type the name Hydraulic power. SpecLatch fills in the key, hydraulic_power, which is what formulas call. The key can't change later.
  3. Type flow as the first input. Click Add input and type head, then click Add input again and type sg.
  4. Next to each input, choose the kind of value it takes: Flow, Length and plain number.
  5. Type the formula: qty(num(flow, "GPM") * num(head, "ft") * sg / 3960, "HP"). The line under it should read Result is Power.
  6. Test it in the calculator under the formula: 130 for flow, 132.6 for head (pick ft if another unit shows) and 1 for sg. The result reads 4.353 HP.
  7. Click Create function. The button stays grey until the formula checks out.
The New function form with the inputs flow, head and sg, the hydraulic power formula, and a calculator showing a result of 4.353 HP.
The calculator runs on the unsaved function, so you can test the math before you create it.

Use it in a calculated field

  1. Open Fields, pick a pump table, click Add field and pick the Calculated tile.
  2. Name the field, for example Hydraulic power at BEP.
  3. In the formula, type hydr and pick Hydraulic power from the list.
  4. Give one value per input, in order: a flow field, a head field and 1 for water. The formula reads hydraulic_power(bep_flow, bep_head, 1).
  5. Click Create field.
A Calculated field's formula calling hydraulic_power with flow and head fields and the number 1, a hint naming the head input, and the line saying it returns power stored in HP.
While you type inside the parentheses, the line under the formula names the input you are on.

If a field holds the wrong kind of value for an input, such as a pressure where a length is expected, the formula shows a red message instead.

What happens after

Every record in the table now shows its hydraulic power, worked out from its own flow and head. The function's page lists the field under Used in. If you change the function later, SpecLatch says how many records it will recompute, and Save & recompute updates them all. You can't delete a function while a field still uses it.

Related

How-toGive fields units and write your first formula
ReferenceHow formulas work
ReferenceBuilt-in functions, with examples
ConceptUnits & formulas