Understanding Expression Builder for Datapoints

Understanding Expression Builder for Datapoints

Expression builders are used to create expression for computing values based on a set of available datapoints, fields, or constants and storing them as realtime or scheduled KPI datapoints.
NotesNote: Expression builder is made available for Realtime datapoints by enabling the computation option.
The three components of an expression builder are
  1. Expressions
  2. Variables
  3. Operators
Expression: An expression can contain up to two variables linked by a single mathematical operator for a single row and can consist of up to five rows, sequentially labelled from A to E. The final expression is constructed using the labels of these rows.



Mathematical Operator: Plus, Minus, Multiply, and Divide are the four supported mathematical operators.



Variables:  Variables represent the values used within an expression.


Realtime Datapoint Variables

Realtime datapoint variables can be of the following types:
  1. Parsing Key
  2. Constant
  3. Datapoint
  4. Field

Parsing Key

Represents the value fetched from the incoming telemetry JSON using the specified parsing key. The value fetched from the JSON will be used in the computation. 

Example: If the telemetry JSON includes a key named temp_k containing the temperature in Kelvin, you can reference temp_k directly in an expression as a parsing key variable and apply the appropriate conversion to derive the temperature in Celsius. The expression always uses the current value received in the JSON, so whenever a new telemetry message arrives, the updated Kelvin value is automatically used in the calculation.




Info
Learn more in detail about Direct Parsing, {Edge Key}, findVal()

Constant

A user defined numeric value that remains the same for all computations.

Example: To convert temperature from Celsius to Kelvin, a constant value of 273.15 is added to the Celsius value in the expression. This value remains unchanged regardless of the incoming Celsius value.

Datapoint

References value stored in another available datapoint. Only datapoints/datapoint templates belonging to the same device, asset, or location instance/model are available for selection and use in the expression.


 
When using a datapoint in an expression, you are given two options: Actual Value and Math Function.



Actual Value: Uses the referenced datapoint value as is, without any modification.

Math Function: Applies the selected mathematical function to the datapoint value, and the resulting value is used in the computation. For example, If a datapoint has a value of -3.6, applying the ABS math function converts it to 3.6. This converted value is then used in the expression for further calculation.



Available Math Functions:

SIN
Returns the sine of the datapoint value.
COS
Returns the cosine of the datapoint value.
TAN
Returns the tangent of the datapoint value.
SQRT
Returns the square root of the datapoint value. 
ABS
Returns the absolute value of the datapoint. It removes the sign of the number, converting negative values to positive while leaving positive values unchanged.
CEIL
Rounds the datapoint value up to the nearest integer.

Example:
If the datapoint value is 2.4, CEIL returns 3.
If the value is -2.4, CEIL returns -2.
FLOOR
Rounds the datapoint value down to the nearest integer.

Example: 
If the datapoint value is 2.4, FLOOR returns 2.
If the value is -2.4, FLOOR returns -3.
ROUND
Rounds the datapoint value to the nearest integer, following standard rounding rules.

Example: 
If the datapoint value is 2.3, ROUND returns 2.
If the value is 2.6, ROUND returns 3.
If the value is -2.5, ROUND returns -3 (rounded to the nearest integer).
PREVIOUS_VALUE
Uses the previously stored value of the datapoint instead of the current incoming value. This is useful for comparisons, rate calculations, or detecting changes over time.

Learn more. 

Example: Consider a scenario where you need a datapoint for power and already have datapoints for current and voltage. You can create the power datapoint by multiplying the current and voltage datapoints in an expression. As new current and voltage data are received, those values are automatically used to calculate and store the updated power value in the power datapoint.


Field

References the value from a numerical field configured in the model that accepts user input.



ExampleAssume you have a Building model with a numerical field called Contracted Demand (kW). This field accepts user input and is manually entered on the Building instance details page. You also have a realtime datapoint called Current Power (kW) that captures live power consumption from an energy meter. In the expression builder, the calculation can reference both values to determine and store the value in a new datapoint called Demand Utilisation. 


Scheduled KPI Datapoint Variable

Scheduled KPI datapoint variables can be of the following types:
  1. Datapoint
  2. Field
  3. Constant

Datapoint

References a value stored in another available datapoint. When using a datapoint while creating a scheduled KPI datapoint, you are given two options: Current Model and Related Model.



Current Model

The Current Model field displays the name of the model to which the Scheduled KPI datapoint is being added. It also lists the existing datapoints configured within that model.

Example: To store the hourly average temperature for a diesel generator, create a Scheduled KPI datapoint. Since the Diesel Generator model already has a Temperature datapoint, select it as the source and set the aggregation to hourly average to compute and store the required value.



Lists datapoints from models that are related to the current model.
Alert
When selecting a related model, ensure that its instances are linked to the current model through a Lookup field. Only values from instances that are associated via this Lookup relationship will be considered. If no such relationship exists, datapoint values from the related model cannot be used in the expression.

Example: Consider a scenario where you want to calculate a metric such as Hourly Fuel Efficiency. In this, the Energy Consumed datapoint is available in the Building model, while the Fuel Consumed datapoint is in the Diesel Generator model. To configure this, create the Hourly Fuel Efficiency datapoint in the Building model, select Energy Consumed as the current model datapoint, and choose the Diesel Generator model as the related model. Then reference its Fuel Consumed datapoint in the expression and apply hourly average aggregation to both values before calculating the ratio.






To establish a relationship, the instances must be linked through a Lookup field. For example, the Building 01 instance can be associated with the DG001 instance using a custom Lookup field named Connected Generator. This Lookup linkage allows the expression engine to correctly fetch the Fuel Consumed value from the associated Diesel Generator instance during calculation.



This ensures that, when calculating the Hourly Fuel Efficiency datapoint for Building 01, the Energy Consumed datapoint value from the Building 01 instance and the Fuel Consumed datapoint value from the associated DG001 instance are used together in the expression.

Aggregation function

KPI datapoints are executed at specific points in time. For a KPI datapoint to be computed, the value of the datapoint selected must be derived using an aggregation function that calculates values over a defined time period.



The following aggregation functions and time periods are available for configuration.

Aggregate Function
Output Value
MAX
Maximum value of the datapoint value aggregated over the specified period.
MIN
Minimum value within the datapoint value aggregated over the set period.
SUM
Summation of all the datapoint values aggregated over the set period.
AVG
Average of all the datapoint values aggregated over the set period.
FIRST_VALUE
First datapoint value received within the set period.
LAST_VALUE
Last datapoint value received within the set period.
STDDEV_POP
Population Standard Deviation of datapoint values aggregated within the specified period.
STDDEV_SAMP
Sample Standard Deviation of datapoint values aggregated within the specified period.
VAR_POP
Population Variance of datapoint values aggregated within the specified period.
VAR_SAMP
Sample Variance of datapoint values aggregated within the specified period.
PERCENT_IN_CONTROL
Percentage of the aggregated datapoint values that fall within the defined control limits during the specified period.

Time Period

Last 1 Hour
Last 6 Hours
Last 12 hours
Today
Yesterday
Last 7 Days
Last 30 Days
Last Week
Last Month
Last 24 Hours
This Week
This Month

Example: To calculate the average temperature for the last 1 hour, configure the KPI datapoint with the AVG aggregation function and select Last 1 Hour as the aggregation timeline. The system aggregates all temperature values received during the last hour and stores the computed average when the KPI is executed.


Field

References the value from a numerical field configured in the model that accepts user input. When using a field while creating a scheduled KPI datapoint, you are given two options: Current Model and Related Model.

Current Model 

Lists fields configured in the same model to which the datapoint is being added. The value entered for the field in the device, asset, or location instance based on the current model is used in the computation.

Example: To calculate the average daily energy consumption per person, you can add a custom field to the Building model called “Today’s Head Count.” This field will be available under the current model datapoints. You can then use it along with the yesterday aggregated Energy Consumed datapoint to compute the per-person daily consumption while configuring the expression.



Lists fields from models that are related to the current model.
Alert
When selecting a related model, ensure that its instances are linked to the current model through a Lookup field. Only values from instances that are associated via this Lookup relationship will be considered. If no such relationship exists, field values from the related model cannot be used in the expression.
Example: If you want to store the per-person fuel consumption, the Fuel Consumed datapoint will be in the Diesel Generator model, while the Today’s Head Count field will be in the Building model. In this case, you can create a scheduled KPI datapoint and configure it to aggregate the day’s total Fuel Consumed value from the Diesel Generator model, then divide it by the Today’s Head Count field from the related Building model.







To enable this calculation, the Diesel Generator instance must be linked to the corresponding Building instance through a Lookup field. This ensures that, during KPI execution, uses the Today Head Count field value from the related Building instance to compute the per-person fuel consumption accurately. For example, the Building 01 instance can be associated with the DG001 instance using a custom Lookup field named Connected Generator. This Lookup linkage allows the expression engine to correctly fetch the Fuel Consumed value from the associated Diesel Generator instance during calculation.



This ensures that, when calculating the Hourly Fuel Efficiency datapoint for Building 01, the Energy Consumed datapoint value from the Building 01 instance and the Fuel Consumed datapoint value from the associated DG001 instance are used together in the expression.

Constant

A user-defined numeric value that remains the same for all computations.




Example: To convert temperature from Kelvin to Celsius, a constant value of 273.15 is used in the expression. This value remains unchanged regardless of the incoming Celsius temperature.

How to Build an Expression 

Expression are created while creating or configuring a new datapoint.

Simple Expression

For a basic expression, fill two variable fields in a row with an operator to compute a value.
Consider a JSON payload where the distance value is measured and sent in centimetres but needs to be converted to millimetres. 
{
distance : 10
}
You can use the expression builder for a straightforward unit conversion. Since 1 cm equals 10 mm, multiplying the incoming value by 10 converts it to millimetres accurately. Set up the expression to multiply the distance datapoint (in cm) by the constant value 10 to store the result in millimetres.
  1. Add a parsing key variable (direct parsing string), and input the parsing key, distance.



  2. Choose the multiplication operator.



  3. Add a constant variable of value of 10 as the second variable.



The expression will now store a computed value of 100 in the datapoint.



Complex Expression

For complex calculations where you need to perform multiple calculations on a value to be stored, you can use multiple rows and edit the expression of the row labels.
For example, consider a JSON message where the temperature value is sent in Fahrenheit, but you want to store data in Celsius.
{
temp_f : 86
}

Now, the formula for converting Fahrenheit to Celsius: (F - 32) * 0.55.
To achieve this computation:
In the first row:
  1. Add the parsing key variable with value temp_f



  2. Choose the Subtraction operator.



  3. Add a constant variable of 32.



  4. Click the + sign to add a second row. 


In the second row:
  1. Add a constant variable of 0.55.


In the expression editor:
  1. Create the formula A*B.


Based on the expression, the resulting value stored in the datapoint will be 30.



Another example is calculating water usage in an agricultural setup. Here, the water consumed is stored in a datapoint, and the number of plants watered can change and is manually entered in a field called "Plants Watered." An expression can be created to calculate the water usage per plant as follows:







      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsEnterpriseOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceAccessible Forms
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit

                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic Forms
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsFormstack alternativeEncrypted Forms

                              Wufoo alternativeSecure Forms

                              TypeformWCAG

                                All-in-one knowledge management and training platform for your employees and customers.

                                            Create. Review. Publish.

                                            Write, edit, collaborate on, and publish documents to different content management platforms.

                                            Get Started Now




                                                              You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                  Manage your brands on social media


                                                                    • Desk Community Learning Series


                                                                    • Digest


                                                                    • Functions


                                                                    • Meetups


                                                                    • Kbase


                                                                    • Resources


                                                                    • Glossary


                                                                    • Desk Marketplace


                                                                    • MVP Corner


                                                                    • Word of the Day


                                                                    • Ask the Experts


                                                                      Zoho Sheet Resources

                                                                       

                                                                          Zoho Forms Resources


                                                                            Secure your business
                                                                            communication with Zoho Mail


                                                                            Mail on the move with
                                                                            Zoho Mail mobile application

                                                                              Stay on top of your schedule
                                                                              at all times


                                                                              Carry your calendar with you
                                                                              Anytime, anywhere




                                                                                    Zoho Sign Resources

                                                                                      Sign, Paperless!

                                                                                      Sign and send business documents on the go!

                                                                                      Get Started Now




                                                                                              Zoho TeamInbox Resources





                                                                                                        Zoho DataPrep Demo

                                                                                                        Get a personalized demo or POC

                                                                                                        REGISTER NOW


                                                                                                          Design. Discuss. Deliver.

                                                                                                          Create visually engaging stories with Zoho Show.

                                                                                                          Get Started Now








                                                                                                                              • Related Articles

                                                                                                                              • Understanding Datapoints

                                                                                                                                Datapoint is a unique time series data represented as a time stamped key- value pair, and is available for assets, devices, and locations in the Zoho IoT application. It is the source of data for other features in the application and is vital in ...
                                                                                                                              • Understand Scheduled KPI Datapoints

                                                                                                                                Scheduled KPI datapoints are computed values based on expressions, with datapoint values from the same model, related models, and field configured for the model, aggregated using a function over a period. These expressions are executed at defined ...
                                                                                                                              • Understanding Fields

                                                                                                                                In Zoho IOT applications, fields are essential components used to collect data as input from users. These fields serve as the primary means through which users can manually provide information to the application. Fields are available on the details ...
                                                                                                                              • Configuring Fields: Datapoints

                                                                                                                                When creating custom datapoints or datapoint templates, users must configure several fields that control how data is processed, and stored. This document provides a detailed explanation of each field and guidance on how to configure them based on the ...
                                                                                                                              • Understanding Assets

                                                                                                                                In Zoho IoT applications, any physical object that is being managed by a sensor or device can be added virtually as an asset. Adding them as assets simplifies monitoring and ensures efficient management of the connected resources. Resources like ...
                                                                                                                                Wherever you are is as good as
                                                                                                                                your workplace

                                                                                                                                  Resources

                                                                                                                                  Videos

                                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                  eBooks

                                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                  Webinars

                                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                  CRM Tips

                                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                                    Zoho Show Resources