Run custom calculations or logic using payload data, formulas, or lookups, and output the result to a new key.
What It Does
The Advanced Function Node lets you apply mathematical expressions, logic statements, string handling, and lookups to fields in your payload. You can also aggregate across time or devices, access Custom Tables, or work with device metadata and timestamps.
Configuration Options
Field | Required | Description |
---|---|---|
Node name | ✅ | Descriptive name for the node |
Output JSON key | ✅ | Field where the result will be written in the payload |
Formula Templates | Optional | Pre-built starting expressions for common calculations |
Choose Formula | Optional | Select from predefined formulas if available |
Function | ✅ | The formula or logic expression to compute |
Decimal places | Optional | Rounds result to N decimal places |
Error handling action | ✅ | What to do if evaluation fails: - Continue – Add Error to JSON - Output zero if value not found |
Step-by-Step: How to Configure the Node
1. Add the Node
Drag the Advanced Function Node into your workflow from the Logic & ETL group.
2. Set the Node Name
Use something descriptive like Calculate Power
, Parse Timestamp
, or Lookup Tag
.
3. Define Output Key
Enter a key (e.g., result
, power_kW
, tempC
) to store the result in the payload.
4. Select a Formula or Template (Optional)
You can select from prebuilt templates or formulas to get started faster.
5. Write the Function
Build your expression using keys from the payload (e.g., [[voltage]] * [[current]] / 1000
).
6. Set Decimal Places (Optional)
Specify how many decimal places to round the result to.
7. Choose Error Handling
Decide what happens when an error occurs during evaluation.
Supported Functions & Formula Syntax
Here are commonly used functions, templates, and syntax structures grouped by category:
Basic Syntax Templates
Template | Description |
---|---|
[[field_name]] |
Gets value from current payload key |
'[[field_name]]' |
Returns value as string |
[[!field_name]] |
Returns empty string if not found |
[[field_name(-1)]] |
Last value from prior payload |
[[field_name(-1dL)]] |
Last value from previous day |
[[field_name(-1dF)]] |
First value from previous day |
[[field_name(same_date)]] |
Returns value from the same timestamp across payloads |
Aggregation Syntax
Template | Description |
---|---|
[[field<device_group.avg>]] |
Average from device group |
[[field<device_group.sum>]] |
Sum from device group |
[[field<device_group.min>]] , max , cnt |
Min, max, or count |
Custom Table Functions
CUSTOMTABLE.AGGREGATE<<custom_table_id.column_name.aggr>>
Performs aggregate on a column from a Custom Table using predefined avg
, sum
, or count
.
CUSTOMTABLE.GETCUSTOMTABLEDATA(...)
Pulls a value from a Custom Table. Supports:
-
Lookup by ID or device
-
Match using a field
-
Return all rows
-
Return single device object
CUSTOMTABLE.LOOKUP<<table.ref_column.target_column.field_name>>
Returns a value from a Custom Table by referencing another field in the payload.
Logic Functions
Name | Template | Description |
---|---|---|
LOGIC.IF |
If(condition, valueIfTrue, valueIfFalse) |
Conditional branching |
LOGIC.IN |
In(value, list) |
Checks if value is in list |
Math Functions
Name | Template | Description |
---|---|---|
MATH.ABS |
Abs(x) |
Absolute value |
MATH.ROUND |
Round(x, decimals) |
Rounds to N decimal places |
MATH.FLOOR |
Floor(x) |
Rounds down |
MATH.CEILING |
Ceiling(x) |
Rounds up |
MATH.POW |
Pow(base, exponent) |
Power function |
MATH.SQRT |
Sqrt(x) |
Square root |
MATH.SIN / COS / TAN |
Sin(x) |
Trigonometric functions |
MATH.LOG |
Log(x, base) |
Logarithm base N |
MATH.RANDOMBETWEEN |
Random(from, to) |
Random integer |
MATH.SIGN |
Sign(x) |
Sign of number |
(Full list available upon request)
Time & Date Functions
Name | Template | Description |
---|---|---|
TIME.DATEADD |
Dateadd(datetime, 'unit', amount) |
Add time to a timestamp |
TIME.DATEPART |
Datepart('unit', 'datetime') |
Extracts part from date (year, month, etc.) |
TIME.TOUNIXTIME |
Tounixtime(datetime, format) |
Convert datetime to Unix time |
TIME.CALCTIMESPAN |
Calctimespan(field, start, end, includeNow) |
Time between two values |
TIME.COUNTDAYSSINCE |
Countdayssince(datetime, format) |
Days since timestamp |
Device & Tag Functions
Name | Template | Description |
---|---|---|
DEVICE.LATITUDE |
<[Latitude]> |
Latitude from device config |
DEVICE.NOW.TZ |
<[System.DeviceTZNow]> |
Current time in device TZ |
TAG.CALC.NAME |
[[value{tag.tag_name.avg}]] |
Aggregate by tag name |
TAG.COUNT.UNIQUE.VALUE |
<[count_unique_tag_values.my_tag]> |
Count of unique tag values |
Repository & Historical
Function | Template | Description |
---|---|---|
REPO.GETDATA |
Repo(id, from, to, filterField, filterVal, targetField, AGG) |
Pull and aggregate repo data |
DATA.QUERYCASSANDRAHISTORY |
Querycassandrahistory('field', N) |
Check value existence in N previous records |
Example Configurations
Example 1: Calculate kW from Voltage × Current
| Output key | power_kW
|
| Function | [[voltage]] * [[current]] / 1000
|
| Decimal places | 2 |
| Error handling | Output zero if value not found |
Example 2: Get Last Day’s Max Temperature
| Function | [[temperature(-1dL)]]
|
Example 3: Custom Table Lookup by Device ID
| Function | GetCustomTableData('EnvLookup', 'tempF', '__device_code__', 'device_id', 'tempField')
|
Q&A
Q: What if a key is missing in the payload?
A: It depends on your error handling setting. You can either insert a 0
or mark an error in the output.
Q: Can I use dot notation for nested keys?
A: Yes — for example, [[payload.data.voltage]]
.
Q: Can I create string outputs?
A: Yes. Enclose field reference in quotes: '[[status]]'
.
Q: What is the difference between Formula Template and Choose Formula?
A: Templates provide reusable syntax, while Choose Formula may populate prewritten functions for speed.