Skip to main content

Using object variables

Object variables allow you to store the metadata of a particular metric or attribute in one single variable. This object variable can then be reference in View components such as input dropdowns, text boxes, and component fields.

The schema (i.e structure) for object variables is generated when a default value or a current value is set and follows the JSON syntax. As such, you need to define key-value pairs.

For example:

{
"key1": "String",
"key2":123,
"key3":true
}

This is then added to the Default Value field when creating or editing the object variable:

A screenshot showing an example of object variables.

Object variables are then referenced in the following ways:

  • PQL editor:

    ${object_one.value}
  • Component fields:

    ${object_one.name}

Benefits of using object variables

There are many benefits to using object variables in your Studio content, including:

  • Reusability: Object variables allow you to define a value, formula, or KPI once and reuse it across multiple Studio assets.

  • Maintainability: When business logic or calculations change, you only need to update the object variable in one place rather than in every Studio asset where it's used. This reduces the risk of inconsistencies and errors.

  • Consistency and reliability: When multiple team members are building dashboards, using shared object variables ensures uniform logic across all reports. This makes dashboards consistent and reliable.

JSON syntax for object variables

Object variables are often stored in JSON. The JSON syntax typically looks like this:

{
  "variables": [
    {
      "name": "VAR_PLANT",
      "type": "OBJECT",
      "objectType": "COLUMN",
      "columnId": "Plant",
      "dataType": "STRING",
      "multiple": false,
      "defaultValue": null,
      "values": [
        { "key": "1000", "label": "Berlin" },
        { "key": "2000", "label": "Munich" },
        { "key": "3000", "label": "Hamburg" }
      ]
    }
  ]
}

This is created using the following fields:

  • Name: The variable’s internal name (VAR_PLANT).

  • Type: "OBJECT" for object variables.

  • objectType: Usually "COLUMN" (linked to a data model column).

  • columnID: The actual column in the Data Model.

  • datatype: "STRING", "INTEGER", "DATE", etc.

  • multiple: True if multi-select is allowed.

  • defaultValue: Optional starting value.

  • values: An array of key-label pairs, representing the selectable items for the dropdown. The values array is structured as key-label pairs:

    { "key": "1000", "label": "Berlin" }
    • key: The actual value stored in the variable (used in PQL queries).

    • label: The human-readable name shown in the View component for users.

Example of using object variables in input dropdowns

Object variables are perfect for input dropdowns in Views. This is because they pull real column values from your Data Model, let users select dynamically, and make your Views interactive and reusable without hardcoding filters.

Suppose you have a dashboard where users should filter by Plant:

  1. Create an object variable VAR_PLANT linked to the column Plant.

  2. Add a input dropdown that displays all distinct plants from the Data Model.

    ${object_one.name}
  3. When a user selects "Plant = 1000", the variable VAR_PLANT stores 1000.

  4. You can now use VAR_PLANT in your PQL filters, e.g.:

    FILTER "Plant" = ${VAR_PLANT}