How to compare string values using formula

This tutorial shows how to use formulas in TagoIO Blueprint dashboards to compare string values and display user-friendly outputs. We’ll cover two common cases:

  • Card widget: show “Online” or “Offline” based on a device status string.
  • Chart widget: convert a string status into numeric values (1/0) for time-series visualization.

Some TagoIO widgets let you apply a formula to the incoming value. This is useful to:

  • Map internal codes to readable labels (e.g., “on” → “Online”).
  • Convert strings to numbers for charts or conditional visuals.

We’ll use the equalText helper in widget formulas to compare string values reliably.

Note: Image links are preserved from the original content. The final “end result” image for the chart is missing.

Prerequisites

  • A Blueprint dashboard in TagoIO.
  • Variables:
    • device_status for the Card widget example.
    • lamp_status for the Chart widget example.
  • A widget with a data source set to “Fixed” when applying a single-value formula.

Card Widget: Map “on” to “Online” and everything else to “Offline”

We’ll display the device_status variable in a Card widget and transform the raw value into a user-friendly label.

  1. Enter edit mode:

    • Click the pencil icon (top-right of the dashboard).
    • On the Card widget, click the three dots menu and open the edit panel.

  2. Configure the Card:

    • Title: set to Device status.
    • Options: disable “Show variable names” and “Show mini-chart” to keep the card clean.
  3. Add the formula:

    • Go to “Formula and unit” and click “Enable formula”.
    • Ensure the data source for this value is set to “Fixed”.
    • Use this formula:
      equalText("$VALUE$", "on") ? "Online" : "Offline"
      
    • Save the widget.

Notes:

  • equalText compares text without worrying about case sensitivity or extra spaces in many cases. If your data includes variations (e.g., “On”, “ON”), equalText handles them.
  • If you compare numbers, do not use quotes around the numeric literals. For example: "$VALUE$" > 10 ? 1 : 0 should become $VALUE$ > 10 ? 1 : 0 when the incoming value is numeric.

End result preview for the card:


Chart Widget: Convert “on”/“off” to 1/0 for Step Line

We’ll visualize lamp_status history by converting the string value into numbers so the chart can plot it cleanly as a step line.

  1. Create or edit the Chart widget.

  2. Title: set to Lamp status history.

  3. Data source:

    • In “Data from”, select the variable that stores the lamp’s status, e.g., lamp_status.
    • Click the gear icon in the top-right of the “Data from” section to open “Visual” and “Formula and unit”.

  4. Add the formula:

    • Open “Formula and unit”.
    • Click “Enable formula”.
    • Use this formula:
      equalText("$VALUE$", "on") ? 1 : 0
      
  5. Visual settings:

    • Go back to the main panel for the chart widget.
    • In “Visual”, set “Line shape” to Step to show clear state transitions.
  6. Save the widget.

After applying the settings above, you should see the series switch between 0 and 1 over time with a step line, where 1 represents “on” and 0 represents “off”.