@Transform (Formula Language)

Applies a formula to each element of a list and returns the results in a list.

Note: This @function is new with Release 6.

Syntax

@Transform( list ; variableName ; formula )

Parameters

list

Text, number, or time-date list. The list to be acted upon.

variableName

Text. The name of a variable. Use this variable in the formula to refer to the list element being acted upon.

formula

Valid formula that evaluates to a result. The remainder of @Transform after the second parameter is the formula that is applied to each element of the input list. The formula must return a value.

Return value

list

Text, number, or time-date. The result of the transformation on the input list. The first value returned by the formula determines the data type of the list. Subsequent return values must be of the same type.

Usage

An iteration of the formula can return a list, which adds multiple values to the return list.

@Transform returns an error if any iteration of the formula returns an error.

If an iteration of the formula returns @Nothing, no element is added to the return list.

Examples

  1. This formula returns a 3-element list whose values are 2, -2, and 4.
    @Transform(OriginalList; "x";
    @If(x >= 0; @Sqrt(x); -@Sqrt(@Abs(x))))
  2. This formula returns the same as the previous one. However, if OriginalList is null, this formula returns null rather than an error.
    @If(OriginalList = @Nothing; @Nothing;
    @Transform(OriginalList; "x";
    @If(x >= 0; @Sqrt(x); -@Sqrt(@Abs(x)))))
  3. This formula returns a 2-element list whose values are 2 and 4.
    @If(OriginalList = @Nothing; @Nothing;
    @Transform(OriginalList; "x";
    @If(x >= 0; @Sqrt(x); @Nothing)))
  4. This formula, when used in a hotspot button creates a field called originalCorrected that adds an asterisk to the beginning of each element in the "original" text list if it does not already have one.
    FIELD originalCorrected := @Transform(original;"var";
    @If(@Begins(var;"*");
    var;
    "*" + var))