Skip to main content

Expression Widgets (Value, Distribution, Statistical, Table)

DataFromSky avatar
Written by DataFromSky
Updated this week

Expression Widgets let you create custom analytics directly inside FLOW using simple scripts — similar to formulas in Excel. You can combine or adjust the outputs of other widgets to get exactly the data and overviews you need. Visually, they look just like ordinary widgets — you can name them and visualize them. The key difference is the Expression field, where you define the script that calculates the value.

How Expression Widgets Work

Expression Widgets allow you to write your own scripts in JavaScript that use data from other widgets as variables. This makes them a flexible tool to further expand the possibilities of data collection and presentation.

Common use cases may include:

  • Calculating the number of free parking spaces

  • Grouping or reclassifying vehicle categories

  • Measuring traffic congestion length

You can add a new Expression Widget by clicking Add Expression Widget at the bottom of the dashboard. There’s no limit to how many you can create.

Supported Widget Types are:

  • Value

  • Statistical Value

  • Table

  • Distribution

  • String Value

  • Events

Expression Inputs

In your script, you can use any widget value on the dashboard as an input variable.

You can use:

  • Value widgets, Statistical value widgets, and other Expression widgets as input variables.

  • Constant values — real or integer numbers.

  • Basic mathematical operators — +, -, /, *.

  • If-else and switch statements, loops, and other JavaScript control structures.

  • Comparison operators — <, >, ==, <=, >=.

  • Dot notation (.) for additional traffic data properties like:

    • .startDataTime()

    • .endDataTime()

    • .isValid()
      (These functions allow filtering of data based on time or other conditions.)

  • Your own functions, defined as:
    function myFunction(p1, p2) { return p1 * p2; }

All available input variables from your dashboard are listed in the Inputs section of the Expression Widget. To insert a widget value into your script, simply click on the widget name. This automatically inserts the widget reference in the following format:

$Widget ID"Widget name"

For example, if the widget ID is 3 and the name is "Level of service", the reference looks like:

$3"Level of service"

For Statistical Value Widgets, you can select which specific statistic (e.g., mean, max) to use from a dropdown menu when clicking on the widget name.

Example: Calculating the Number of Free Parking Spaces

A typical use case for Expression Widgets is calculating the number of free parking spaces in a parking lot.

  1. Add a Zone and set it to Live mode.

  2. Add a Value Widget to count the number of currently occupied spaces in that zone.

  3. Use an Expression Widget to calculate free spaces by subtracting the occupied count from the total capacity.

Example script (for a parking lot with 18 spaces):

18 - $16"Parking zone - n. of currently occupied spaces"

In this example, widget ID 16 provides the number of occupied spaces. The script subtracts this number from the total capacity (18).

Publishing Results via REST API

The power of the Expression Widget lies in its ability to process and finalize your data directly within FLOW before sharing it further. If you want to publish the result through the REST Sink API, simply select the Publish as simple value REST sink option.

Learn more about sinks and the REST API in these articles:

  • Introduction to data sinks and FLOW Insights' public API

  • Using REST sinks for traffic data retrieval

What Next?

Learn more about widgets and sinks in FLOW, explore time processing, or check out other widget types such as Value and Movement Set Statistics. Use the FLOW Public API to access data from widgets and sinks and integrate it with your external systems.

Make your traffic analytics smarter and more connected with FLOW.

Did this answer your question?