Skip to content

Metrics#

A metric is what is counted, added up or calculated on a fact table: the number of invoices, the total amount, the average ticket, the margin, the weight of each zone in the total. Users choose it in the wizards and ECenter calculates it in each cell of a cube, each point of a chart or each entity of a map.

Before you start#

  • You need Metadata administration.
  • The metric belongs to a fact table: create the table first (see Fact tables).

The metric types#

Type What it calculates Example from the demonstration
Number of rows Without a column, it counts the records; with a column, those that have a value in it. “Número de Facturas” (number of invoices)
Sum The sum of a column. “Importe total” (IMPORTE_TOTAL)
Average The average of a column. “Ticket medio” (average ticket)
Minimum and Maximum The lowest or highest value of a column. “Factura mínima”, “Factura máxima” (smallest and largest invoice)
SQL expression An aggregate SQL expression of the engine, which the database calculates in each cell. “Importe neto” (net amount), “Clientes distintos” (distinct customers)
Formula over metrics A formula on other metrics, which ECenter calculates cell by cell with their values, without going to the database. “Margen sobre ventas (%)” (margin on sales), “Peso en la zona (%)” (weight in the zone)

Register a metric#

  1. In the Structure tree, open the menu of the fact table (or of its Metrics section) and choose New metric…. It is also in the table's panel.
  2. Type the Name and, if you want, the Business description.
  3. In Calculation, choose the Type and the Column, the Expression or the Formula.
  4. Choose the Default total and the Format.
  5. Click Create metric.

The metric is created last in its table, with the default access privilege; the privilege is changed once it is created.

The panel of the Importe neto metric of Líneas, with its expression, the result of Test and the format previewThe panel of the Importe neto metric of Líneas, with its expression, the result of Test and the format preview
The panel of the Importe neto metric of Líneas, with its expression, the result of Test and the format preview

General#

Option What it is
Name The name users see. Up to 100 characters.
Business description Optional. A paragraph that explains what it is, for whoever chooses it and for the agents of the query API and the MCP server. Up to 500 characters.

Calculation#

Column#

In the simple types, Column is the column of the table that is aggregated. In Number of rows it is optional: No column: counts rows.

SQL expression#

An aggregate SQL expression of the database engine. Columns are written [Table.COLUMN], with the alias (or the physical name) of the fact table and the column as the catalog gives it, with its capitals. Examples from the demonstration (PostgreSQL):

-- Net amount of the lines
SUM([Líneas.CANTIDAD] * [Líneas.PRECIO_UNITARIO] * (1 - [Líneas.DESCUENTO_PCT] / 100))

-- Active customers
SUM(CASE WHEN [Clientes.ACTIVO] THEN 1 ELSE 0 END)

-- Average days to collect
AVG([Facturas.FECHA_COBRO] - [Facturas.FECHA_FACTURA])

-- Distinct customers
COUNT(DISTINCT [Facturas.COD_CLIENTE])
  • Type [ (or press Ctrl+Space) to choose the table and the column from a list: the arrows choose, Enter writes it and Esc closes the list.
  • An expression can cite columns of another fact table: the query joins it through its relationships.
  • Up to 2048 characters.
  • Test asks the database for the plan of the metric alone, without saving or running it, and says whether it accepts it. If not, it gives the engine's error. The database plan shows what the engine estimates and Copy copies the statement.

When changing from a simple type to SQL expression, the panel proposes the equivalent expression (SUM([Facturas.IMPORTE_TOTAL])).

Important

The expression is SQL of the connection's engine and the database runs it with the connection's user. If you change engine, review the expressions. If the expression uses columns protected with a privilege other than the metric's, the panel warns of it: whoever sees the metric will see a result calculated with data they may not be able to see.

Formula over metrics#

A formula with the names of the metrics in brackets, + - * /, parentheses and numbers with a decimal point:

[Margen] * 100 / [Importe neto]
  • LEVEL([Importe total], 1) is the value of the metric one level above (the row's upper group). It serves for percentages of its group's total: “Peso en la zona (%)” is [Importe total] * 100 / LEVEL([Importe total], 1).
  • A metric of another table is written with its alias in front: [Facturas.IVA]. If two metrics have the same name, it is written with its identifier (the suggestions insert it).
  • Type [ (or press Ctrl+Space) to choose a metric.
  • The formula is saved with the metrics' identifiers, not with their names: renaming a metric does not break it. The panel shows it below: “It is saved with the identifiers: …”.
  • It is calculated in ECenter, cell by cell: it does not reach the database, so it is not tested against it.
  • Its total is always Recalculate over the totals: the formula is applied to the totals of its metrics.

A formula is only seen by whoever sees all the metrics it uses. If any is protected, the panel warns of it. In the demonstration, “Margen sobre ventas (%)” has no privilege of its own, but only whoever sees the margin sees it.

A metric used by a formula cannot be deleted while the formula uses it.

Default total#

The total type decides how the cube calculates the total rows and columns. Users can change it in each cube; here the default one is chosen.

Total What it does
Sum Adds up the cells. The default for sums, counts and expressions.
Count Counts the cells with a value.
Average The exact average of the records (not the average of the cells' averages).
Weighted average Weights the value of each cell by its number of records.
Minimum and Maximum The lowest or highest of the cells.
Recalculate over the totals Calculates the metric again for each total. In an expression, the database calculates the totals in a separate query; use it in expressions that cannot be added up, such as a COUNT(DISTINCT …) or a percentage.
% increase in the row The increase, in %, between the first and the last value of the row (for example, from one year to the next with the years in columns).
% increase in the column The same between the first and the last value of the column.
No total Does not calculate a total.

When the type changes, the panel proposes the corresponding total: Average for an average, Minimum or Maximum for a minimum or a maximum, and Sum for the rest.

Format#

Format is the mask with which the values are shown. Below, the preview shows how some sample numbers would come out.

Character What it does
0 A digit; if the number does not have it, a 0 is put.
# A digit; if the number does not have it, nothing is put.
, The decimal comma. The decimals are as many 0 or # as there are after it, rounding.
. Separates the thousands, wherever it is in the integer part.
'…' or "…" Text copied as is. The rest is copied too: #.##0,00 €.
; Separates up to three sections: positives, negatives (without the sign) and zero. An empty section uses the positives' one.

The mask is written with the Spanish convention (comma for decimals, period for thousands), as in the metadata of the demonstration.

Examples:

Format 1234,5 −1234,5 0
#.##0,00 € 1.234,50 € -1.234,50 € 0,00 €
0,0 1234,5 -1234,5 0,0
#.##0;(#.##0);- 1.235 (1.235) -

Up to 50 characters. A new metric comes with #.##0.

Access and order#

  • Access privilege: who sees the metric. It is changed with Change…, with the preview of whom it affects (see Privileges and universes).
  • Sort: the position of the metric among those of its table (“It is number 3 of 12 metrics of “Facturas”.”), which is the order in which they are offered to users. It is changed with Up and Down, by dragging in the table's list of metrics or with Alt+↑ and Alt+↓ in the tree. It is saved at once.

User-defined metrics#

In Empowerment Center 7, whoever administered workbooks could create their own metrics (“Gestión de Métricas de Usuario…”, user metric management). The EC7 importer brings them as normal metrics marked User-defined, which are seen with the tree's Origin filter. They are edited, tested and deleted like the others.

In ECenter 8.0 users no longer create metrics: if they need one, whoever needs it asks whoever administers the metadata, who creates it here. A new metric is born in the main metadata; changing a user-defined one keeps its mark.

Frequent errors#

Message What to do
“Choose the column: only the number of rows is calculated without a column.” Choose the column of the sum, the average, the minimum or the maximum.
“Type the expression: an aggregate SQL expression, such as SUM([Table.COLUMN]).” The expression is mandatory in an SQL expression.
The database does not accept the expression, with the engine's error Correct the expression with the engine's error: a misspelled column, a function of another engine or an expression without aggregation.
A metric that cannot be deleted A formula of another metric uses it: the dialog says which one in Prevented by.

See also#