Ubidots Developer Guides
Help CenterAPI ReferenceData APICommunity
  • Welcome to our Dev Guides
  • ⚡️ Getting Started
    • What is Ubidots?
    • Devices, Variables, and Dots
    • Technical FAQs
    • Business FAQs
  • 🧩Integration Guides
    • Industrial IoT
      • Advantech
      • Amplified Engineering
      • AWS
      • Azimut
      • Balena
      • Bivocom
      • CESVA
      • Controllino
      • Digital Communications Technologies (DCT)
      • Everactive
      • Golioth
      • Kepware
      • Kunbus
      • Monnit
      • MultiTech
      • NCD.io
      • Node-RED
      • Omicron IoT
      • Red Lion
      • Robustel
      • Senquip
      • Sielco
      • Siemens
      • Strega
      • vNode
      • WAGO
      • Weintek
      • YuDash
    • Cellular
      • Blues Wireless
      • Digi International
      • Hologram
      • Monogoto
      • Particle
      • Quectel
      • Soracom
    • LoRaWAN
      • AonChip
      • Chirpstack
      • Decentlab
      • Helium
      • ioThings
      • LORIOT
      • Milesight
      • MOKOSmart
      • RAKwireless
      • Sagemcom
      • Seeed Studio
      • Senet
      • The Things Industries
        • The Things Stack
        • The Things Network
    • Sigfox
      • Digital Matter
      • McThings
      • Sigfox
      • Suntech
      • Thinxtra
      • UnaBiz
    • Satellite
      • Swarm
    • Dev Kits
      • Adafruit
      • Advantech
      • AloriumTech
      • Arduino
      • Blues Wireless
      • DFRobot
      • Dragino
      • Electric Imp
      • Espressif Systems
      • McThings
      • Microchip Technology
      • Onion
      • Particle
      • Pycom
      • RAKwireless
      • Raspberry Pi
      • Seeed Studio
      • Sodaq
      • STMicroelectronics
      • Texas Instruments
      • Thinxtra
      • Verse Technology
    • Weather
      • Weather Plugins
      • Ambient Weather
    • Tools
      • Gambit Communications
      • PubNub
  • 📊Dashboards & Widgets
    • HTML Canvas
      • 3rd party packages
      • Preload Dashboard data
      • Built-in library
        • Properties
        • Methods
        • Listening events
        • API
      • Examples
        • Basics
        • Create an LCD screen with the HTML Canvas
        • Interacting with dashboard data
        • Change header's custom style
        • Adding real time using Socket.IO
        • Delete Variable data from a Device
        • Delete Variable data from Groups or Types of Devices
        • Navigation through Dashboard
        • Using a React library
      • Code editor
        • HTML Tab
        • CSS Tab
        • JavaScript Tab
    • Custom UI
      • Paragraph
      • Input combo
        • Text
        • Numeric
        • Numeric with buttons
        • Date
        • Time
        • Toggle
        • Dropdown
        • Multiple selection dropdown
      • Button
    • Custom Style
      • Dashboards
      • Widgets
    • Line chart
    • Pages
      • Getting started
      • Development
      • API
        • Page creation
        • Publish
  • 🤖UbiFunctions
    • Getting Started
      • Creating an UbiFunction
      • Coding an UbiFunction
      • Testing an UbiFunction
      • Authentication
      • Execution Time
      • Logs
    • Runtimes
      • Python
      • NodeJS
      • Custom Runtimes
    • Invocation
      • Time-based Trigger
      • HTTPS
      • MQTT Publish
      • Ubidots Event
    • Advanced
      • Account Token
      • Execution time
      • Raw Functions
      • CORS Policy
      • Async Execution
      • DaaS (Decoder as a Service)
      • Developing and Managing UbiFunctions with Ubidots CLI
    • Examples
    • Specs and Limits
    • Storage
      • File Storage API
      • Mutiple files
  • 🧩Plugins
    • What is a plugin?
    • Public vs. Private
    • Public plugins
      • Cron
      • Webhook
    • Private Plugins
      • Cron
      • Webhook
      • Widget
      • Device
    • Plugins development
      • Getting started
      • Cron
      • Webhook
      • Widget
      • Device
      • view.xml
      • view_widget.xml
    • Plugins deployment
      • Cron and Webhook
      • Widget
      • Device
    • Using the plugins
      • Cron and Webhook
      • Widget
      • Device
  • 📈SYNTHETIC VARIABLES
    • Getting started
      • Creating synthetic variables
      • Synthetic Variables' editor
    • Expressions
      • Mathematical
      • Date range
      • Rolling
      • Special functions
    • Specs and limits
    • Examples
      • Mathematical
      • Date range
      • Rolling
      • Special functions
  • ⌨️Developer tools
    • Javascript SDK
      • Overview
      • Getting started
      • Ubidots class
        • Get methods
        • Filter methods
        • Ubidots objects
          • Entity object
          • Paginator
      • Examples
    • CLI
      • Overview
      • Installing
      • Usage
      • SDK for UbiFunctions
  • 🏗️Apps
    • App builder
      • Custom sidebar
Powered by GitBook
On this page
  • _
  • Examples

Was this helpful?

Export as PDF
  1. SYNTHETIC VARIABLES
  2. Expressions

Special functions

We developed functions to facilitate working with time series, fill in gaps or missing data points, allow conditional statements, cumulative sums and shift the position of the elements inside.

fillfillfill_missing()missing()missing()

Many synthetic expressions require two or more variables. In those cases, each of the values to be computed must have the same timestamp, otherwise the engine will not compute the expression. Fill missing() can help in these cases, as it fills the gaps where there is a missing value in any of the variables used within the expression. The syntax for this function is as follows:

fill_missing (expression, <first_fill>, <last_fill>, <fill_value>)

Parameters
Description
Value
Mandatory

Expression

The expression to be computed

N/A

YES

first_fill

None: No fill will be done.

NO

last_fill

NO

fill_value

This is the value that will be used to fill in the blanks in the variables.

Any integer or float.

NO

Examples

Expression
Description

fill_missing(temperature * humidity)

Fills the missing gaps starting in the most recent data in the time series for the temperature and humidity variables and then calculates its product.

fill_missing(temperature * humidity, fill_value = 1)

Fills the missing gaps with the value "1" starting in the most recent data in the time series for the temperature and humidity variables and then calculates its product.

fill_missing(temperature * humidity, "first_fill" = "bfill")

Fills the missing gaps starting in the oldest data in the time series for the temperature and humidity variables and then calculates its product.

where()where()where()

A conditional expression is required in some cases to generate an outcome. The where() function is an if-else statement that executes one of two actions depending on whether the input condition is true or false. The syntax for this function is as follows:

where(condition, operation if true, operation if false)

It computes the operation operation_if_true, if the condition is true. Otherwise it will execute the operation_if_false.

diff()diff()diff()

This function calculates the difference starting at the last element in a time series and the next separated by a specified number of steps. The syntax of this function is as follows.

diff(<variable>,<steps>)

Parameter
Description
Value
Mandatory

Variable

Variable label

YES

Steps

Number of places separating two components in a time series, starting with the most recent element.

Any positive integer no bigger than the total of elements in the time series

YES

shift()shift()shift()

The function returns the variable's values in the time series shifted by the given number of steps. The syntax of this function is as follows.

shift(<variable>,<step> )

Parameter
Description
Value
Mandatory

Variable

Variable label

YES

Step

Number of places (+/-) the time series will be shifted to.

Positive or negative integer

YES

Cumsum()Cumsum()Cumsum()

This function returns the cumulative sum of a time series. The syntax of this function is

cumsum(x)cumsum(x)cumsum(x), where xxx is the variable to be calculated.

PreviousRollingNextSpecs and limits

Last updated 6 months ago

Was this helpful?

Determines how the gap should be filled. By default set to .

: Fills the gaps forward, starting in the most recent data point.

: Fills in the gaps backward, starting in the oldest data point.

Determines how the gap should be filled at the end of the time series. Comes in handy when you have to fill all gaps in the variables. By default the function is set to .

: Fills the gaps forward, starting in the most recent data point.

: Fills in the gaps backward, starting in the oldest data point.

: No fill will be done.

It shows the measurements of a sensor as a of data points that vary over time. Also known as , it's identified by a variable label.

It shows the measurements of a sensor as a of data points that vary over time. Also known as , it's identified by a variable label.

📈
ffillffillffill
ffillffillffill
bfillbfillbfill
nonenonenone
ffillffillffill
bfillbfillbfill
nonenonenone
time series
"dots"
time series
"dots"