This is an old revision of the document!


Calc

Performs a calculation on either a frame or the table items inside the frame.

Parameters

NameDefaultMeaning
nameThe name of the final attribute/column
valueThe value to be written. Substitutable.
whereA condition that must be met for the calculation to happen.
elseThe value to set if the where condition is not true. If blank, no value is set.

Description

This function performs a calculation on a frame, or - if the frame contains a table - the individual items within the table.

This will normally be applied to every column/frame, unless a where condition is specified. If a 'where' condition exists, the calculation will only happen on frames and columns that match the condition.

Example

If the frame contains the following attributes…

AttributeValue
Width100
Height100
{
   "type": "calc",
   "name": "Area",
   "value": "{Width} * {Height}"
}

The final results will include the Area attribute with a value of 10,000. If 'Width' and 'Height' were in the table instead, a new column called 'Area' would be added.

Empty Values & Overwriting

Note that if you are using the where condition, values are only written into table rows if either…

1) The row doesn't have a column, in which case the default value is blank, or
2) The row has a column value, and the else value is set.

Otherwise, the calculation will simply skip over rows that fail the where condition.