Skip to Content

Metrics

Combine single value metrics in an expression

Add a dashboard card that calculates one number from other single value metrics, for example a ratio.

Before you start

  • The dashboard has at least one metric with the Single Value chart.
  • Your role has Create on Elements. Admins have it by default.
  • The datasource is not OpenSearch or Elasticsearch.

Steps

  1. Open the dashboard.

  2. Select Add element.

    Dashboard header toolbar with the Add element icon button highlighted
    Add element is the third icon in the dashboard toolbar.
  3. Optional: enter a Title and Description.

  4. In Element Type, select Metric Expression.

    Add Element panel with the Element Type list open and Metric Expression highlighted
    Metric Expression is the third choice in Element Type.
  5. In Metrics, select the single value metrics to use. The list shows their names. Find each Metric ID on Home > Metrics, in the Metric ID column.

    Add Element panel with Metrics set to Total units sold and Total profit, highlighted
    Metrics lists only the dashboard's Single Value metrics.
  6. In Metric Expression, enter the formula. Write each metric as {{Metric ID}}, for example {{revenue_total}}/{{order_count}}.

    Metric Expression field with {{total_profit_b3ZXOH}}/{{total_units_sold_P6rzza}}, highlighted
    Write each metric as its Metric ID in double braces.
  7. Optional: set Font Family, Font size and Font Weight.

  8. Select Save.

The card shows the result of the formula.

How the formula works

Databrain runs the formula as SQL on your datasource. Each {{Metric ID}} becomes that metric’s single value.

  • Use +, -, *, /, parentheses and the SQL functions your datasource supports. For example: ROUND({{revenue_total}}/{{order_count}}, 2).
  • Put an operator in double quotes to show it as text instead of calculating it. For example, {{won_deals}}"/"{{all_deals}} shows 12 / 40.
  • A metric that is not a single value is left out of the formula.

Find a metric’s ID in Home > Metrics in the Metric ID column.

If something goes wrong

  • No Single Card metrics found. Create a metric to enable metric expression. Add a metric with the Single Value chart to the dashboard.
  • Metric Expression is not available in your datasource. OpenSearch and Elasticsearch do not support it.