Skip to Content

Metrics

Add a dynamic property

Add a named value to a metric's SQL that changes with a filter.

A dynamic property is a named value. You write it as [[name]] in the query, and Databrain puts in the value when the metric runs.

Steps

  1. Open the metric in the metric builder.

  2. Select Dynamic Property in the Query toolbar.

    Metric builder Query toolbar with Join, Filters, Sort, Group By and Dynamic Property, Dynamic Property highlighted
    Dynamic Property is the last button in the Query toolbar.
  3. Select Property.

    Dynamic Property popover with No properties yet and the Property button highlighted
    Select Property to add a new one.
  4. In Property Name, enter a unique name, for example region.

    New property panel with Property Name store_state highlighted and [[store_state]] under it
    The line under the name shows how to write it in the query.
  5. In Property Type, select Auto or Custom.

    New property panel with the Property Type choice Auto or Custom highlighted
    Property Type: Auto or Custom.
  6. Fill in the fields for the type. See the table below.

    New property panel with Dataset dbn-demo_sales, column store state and the aggregate field highlighted
    For Auto, pick the dataset, the column and, if you need one, an aggregate.
  7. Optional: in Default Value, enter the value to use when nothing is picked.

  8. Optional: link the property to a filter. See below.

  9. Select Create.

  10. Write [[region]] in the query where the value goes.

The Dynamic Property button shows how many properties the metric has.

Property TypeFields
AutoSelect a table, Select a column, Select an aggregate. Optional client column to scope the values to each client.
CustomSQL Editor with a query that returns the values, and Column Name: the column or alias from that query.

Databrain runs a Custom query to check it before it saves.

Make the property follow a filter

  1. Select Depend on, then Add Option.

    New property panel scrolled down with the Depend on section highlighted above Discard and Create
    Depend on is at the bottom of the New property panel.
  2. Select a Filter type: Dashboard Filter, Metric Filter or Client Filter.

  3. In Select the Filter, select the filter.

  4. In Column Name for Dependency, enter the alias from the query.

When a viewer changes that filter, the property gets the new value.

If something goes wrong

  • Property name should be unique. Another property has this name. Enter a different name.
  • Client Filter is not available for a Custom SQL property. Set Property Type to Auto.
  • Client Filter is not available on a database-tenancy workspace. Use a Dashboard Filter or Metric Filter.