 # Custom Functions

Would really love support for custom formula functions. Not a major blocker at the moment, but a lot of my formulas could be shorter:

``````Sequence(0, thisRow.[h (m)]/[delta (meters)], 1).FormulaMap(
((((CurrentValue+1)*[delta (meters)]) * (1/10)) + 1)
*
Max(
(Pi() * thisRow.[r (m)] * SquareRoot(
Power(thisRow.[r (m)], 2) + Power(thisRow.[h (m)] - (CurrentValue*[delta (meters)]), 2)
)
)
- (Pi() * thisRow.[r (m)] * SquareRoot(
Power(thisRow.[r (m)], 2) + Power(thisRow.[h (m)] - ((CurrentValue+1) * [delta (meters)]),
2))
)
, 0)
).Sum()
``````

Could become:

``````Function(SurfaceAreaCone, depth, thisRow,
(Pi() * thisRow.[r (m)] * SquareRoot(
Power(thisRow.[r (m)], 2) + Power(thisRow.[h (m)] - (depth * [delta (meters)]),
2))
),
Sequence(0, thisRow.[h (m)]/[delta (meters)], 1).FormulaMap(
((((CurrentValue+1)*[delta (meters)]) * (1/10)) + 1)
*
Max(
SurfaceAreaCone(CurrentValue, thisRow)  -  SurfaceAreaCone(CurrentValue + 1, thisRow)
, 0)
).Sum()
)
``````

Becomes a lot easier to read, and there are less opportunities for bugs.

The signature for this function is essentially:

``````Function(FunctionName, arg1, arg2, ..., argN, FunctionBody, ExecutionContext)
``````
2 Likes