Qubit Docs العربية

Metric definitions

A metric definition says what to measure, which rows to include, and how the number behaves over time. You define new metrics in the semantic layer. Metrics saved directly against a table use a simpler dialog.

Defining a metric in the semantic layer

  1. On the Metrics page, click Create metric. This opens the Semantic Layer page. You can also open it from Data Catalog with Semantic model.
  2. In Build, check that the business object you want to measure is listed under Business objects. If it is not, add it first. See Editing fields.
  3. Under Metrics, click Add metric and fill in the fields below.
  4. Click Check to validate the model against your live schema.
  5. Click Save, review the list of changes, then click Confirm and save.

Qubit computes the new metric after you save, and it appears on the Metrics page.

Metric fields

  • Name: the name shown on the Metrics page and on dashboards.
  • Measures: the business object the metric is calculated on.
  • How the number is calculated, chosen with Column, Formula, or SQL:
    • Column: pick a Calculation (Sum, Average, Count, Count distinct, Minimum, or Maximum) and the column under Of column. With Count, leave Of column empty to count rows. Counting rows needs a primary key on the business object.
    • Formula: write a SQL expression for a number no single calculation fits, such as a rate or a share. Qubit still applies the breakdowns, filters, and joins you set.
    • SQL: write the whole query yourself. It runs exactly as typed, must be a single statement that only reads, and returns one fixed result. Breakdowns and filters set on the metric do not apply to it.
  • Measurement type: Adds up over a period for totals such as revenue or order count, or Latest value for current levels such as active subscribers.
  • Reporting period: All time, Week, Month, Quarter, or Year. A period reports the current period so far and compares it with the same span of the previous one. It is not available for Latest value.
  • Unit: for example SAR, %, or count.
  • Description: what the number includes and leaves out. The Assistant reads it.
  • Category: groups the metric on the Metrics page.
  • Name in Arabic and Description in Arabic: shown when the app is in Arabic.
  • Split by: the dimensions the number can be broken down by. Names with a dot come from a joined business object, for example store.region.
  • Only count rows where: filter conditions, each made of a Column, an operator under Is, and a Value. A row counts only when every condition holds.

Defining a metric in Code

In Code, a metric is an entry under metrics in the YAML document. Use Insert, then Metric, to add one in the right place, or type it yourself. The Syntax guide tab describes every field. Code also lets you write filters as several all groups. A row then counts when it matches any one group.

Metrics saved against a table

Some metrics are saved directly against a table instead of on a business object:

  • Metrics the Assistant creates directly from a chat.
  • Metrics Qubit creates for single-number cards when the Assistant generates a dashboard.
  • Older metrics made before the semantic layer.

The semantic layer lists these under Outside this model in its Used by tab and does not change them when you save the model. Clicking one on the Metrics page opens the Edit metric dialog:

  1. Edit Name, Description, Name (Arabic), and Description (Arabic).
  2. If the workspace has more than one connection, pick the Data source.
  3. Describe the calculation in plain language under Definition.
  4. Click Compile, or Recompile if the metric already has a definition. Qubit turns your description into a Compiled definition that shows the Computation and any Filters.
  5. Review Over time (Latest value or Total over the period), Unit, Reporting period, and Category.
  6. Click Save. Save stays off while the compiled definition has issues.

When you save a changed definition, Qubit recalculates the value and rebuilds the trend in the background.

Defining metrics with the Assistant

The Assistant can define metrics for you when the Metrics & semantic model capability is on and you have the Owner or Admin role. It can add metrics to the semantic model, or create a metric directly against a table. Changes it makes to the model are validated before they are saved. See Creating a metric and Capability toggles.