[Calculated] section |
The [Calculated] section lets you define a function that operates on input data. For each name/value pair in this section:
This topic contains the following sections:
On the right-hand (value) side, the calculation you define can use one or more of the built-in functions, plus any of these operators:
TotalWeight = Input.EmptyWeight + Input.LoadWeight
This defines a calculated variable named TotalWeight, which you can use in the [Filter] section or [Output] section.
You can also define a calculated variable using an if-then-else (ternary) operator.
In this example, a CalculatedSpeedUnit variable is used to dynamically set the units used for the LastLocationSpeed column based on the value of the BaseAddress column’s Country subfield:
[Template] TemplateVersion = 1.0 TableID = Unit-1.0 TemplateName = RetrieveUnit Intent = Retrieve OrderBy = Input.Tag Format = JSON [Calculated] CalculatedSpeedUnit = Input.BaseAddress.Country == "USA" ? "mph" : "kph" [Output] Tag = Input.Tag Id(test) = Input.Id DriverName = Input.DriverName DriverId = Input.DriverId BaseAddress = Input.BaseAddress LastLocationSpeed(CalculatedSpeedUnit) = Input.LastLocationSpeed
Variables you set in the [Calculated] section can be used in the Filter or Output sections.