• /
  • EnglishEspañolFrançais日本語한국어Português
  • EntrarComeçar agora

Work with nested variables

Nested variables let you create dynamic, dependent relationships between variables on your dashboards. This allows you to:

  • Reuse dashboard variables and dynamically change what's shown, especially for filtering based on other variables' data.
  • Create parent/child relationships in variables, forming a tree structure where you can select different levels of filters.

Use case

Imagine you've created an Env variable to select an environment (for example, production and staging). You want to update a Machine variable with a list of machines based on the selected environment. Directly embedding the Env variable in a WHERE condition for Machine isn't supported in a standard setup.

Example:

  • Variable Env = production or staging
  • Variable Machine = SELECT uniques(machine) FROM Table WHERE env in ({{Env}})

This direct approach isn't supported without nested variables. Nested variables solve this by allowing your Machine variable's query to dynamically reference the value of your Env variable.

How to use nested variables

To implement nested variables, follow these steps:

  1. Go to a dashboard you can edit.
  2. Create your parent variable (for example, env) by using the Add Variable function:
    FROM Transaction
    SELECT uniques(environment)
  3. Create another variable (for example, variable_cluster) and, when defining it, place {{env}} inside the textbox:
    FROM Table
    SELECT uniques(machine)
    WHERE env IN ({{env}})
  4. Save both variables.
  5. Go to your dashboard and interact with the variable's values. They should automatically change based on the nested variable value selection.

Now you can use your child variable inside any widget on your dashboard. When your variable_cluster changes, your widget will also change!

Limitations

When you use nested variables, be aware of the following limitations:

  • Parent variable selection required for child definition: Make sure your env variable has selected values when you define your machine variable. Otherwise, the machine query will return no results.
  • Variable selection required for widget usage: Ensure the variable has selected values when you use it inside widgets. Otherwise, the widget's query will return no results.
  • Deletion impact: If your env variable is deleted, your machine variable may show errors when loading.
  • Cleared values: If your env variable's values are cleared, your machine variable will continue to show values based on env's previous selections.
Copyright © 2025 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.