KPI
The KPI widget shows a single key figure: open invoices in euros, number of open requests, delivery rate in percent. The number comes from an SQL query and appears as a large value, as a gauge with green, yellow and red ranges or as a traffic light.
Setting up
In the Dashboard Designer the KPI widget has two buttons: Configure data source and Edit display. The widget shows a value only once both are set.
Data source
- Source: choose SQL query. The card Data object is marked “Coming soon” and cannot be selected yet.
- Query: enter SQL, Run test shows the number of rows and the first row as a preview, Apply saves.
The KPI takes from the first row the first column whose value is a number; the column name does not matter. If the query returns no row or no number, the widget shows No data. This is why COALESCE(SUM(…), 0) pays off: without a match, 0 appears instead of “No data”.
Display
- Value only: large number with unit.
- Gauge: semicircular scale from Minimum (default 0) to Maximum (default 100) with three color ranges.
- Traffic light: three lamps, the one matching the value lights up, the value is shown below.
Unit is available for all three: no unit, € – Euro, $ – US dollar, % – percent, pieces, hours, minutes, kilograms, kilometers, days or Custom… with own text. The unit determines the format: € becomes 12.345,67 €, $ becomes $1,234.56, % becomes 87,5 %, everything else is formatted in German notation with the unit after it.
Direction and thresholds
Gauge and traffic light need a direction and two thresholds:
| Which direction is good? | Fields | Result |
|---|---|---|
| Higher is better (revenue, delivery rate) | Green from, Yellow from | above green, in between yellow, below red |
| Lower is better (sick notes, complaints) | Green up to, Yellow up to | below green, in between yellow, above red |
Default values are 70/30 for the gauge and 80/50 for the traffic light. The Default button sets the gauge thresholds to 30 % and 70 % of the range. When the direction changes, the two values swap places. If the green value is on the wrong side of the yellow value, the dialog reports this and cannot be applied. A preview shows the gauge or traffic light with the set thresholds.
Example “Kranke Mitarbeiter” (employees on sick leave): Lower is better, Green up to 1, Yellow up to 5. Result: 0 to 1 green, 2 to 5 yellow, from 6 red.
On the dashboard
The value loads when the dashboard opens and on Refresh dashboard, and also via the refresh icon in the widget header. When the value changes, it flashes briefly. The KPI has no period of its own: on the dashboard alone, the placeholders @periodStart and @periodEnd stand for the current month. If the KPI sits in a filter container with a period, it follows that selection. If the query fails, the widget shows only an error icon; the cause is found by running the same query in Data analytics.
Examples
The examples use the table app_invoices of the invoicing app with the fields app_invoice_date (invoice date) and app_gross_total (gross amount).
Total revenue in the selected period
SELECT COALESCE(SUM(app_gross_total), 0) AS umsatz
FROM app_invoices
WHERE app_invoice_date >= date(@periodStart)
AND app_invoice_date < date(@periodEnd)
Display Value only, unit € – Euro, title “Bruttoumsatz” (gross revenue). On the dashboard alone, the KPI counts the current month; in a filter container with a period it counts whatever viewers select there. For a fixed period without a filter, such as since the start of the year, the condition is WHERE app_invoice_date >= date_trunc('year', current_date).
Change versus the previous month as a traffic light
There is no trend indicator; the change is calculated in SQL and shown as a traffic light:
SELECT CASE WHEN vormonat = 0 THEN NULL
ELSE ROUND((aktuell - vormonat) / vormonat * 100, 1) END AS veraenderung
FROM (
SELECT COALESCE(SUM(CASE WHEN app_invoice_date >= date_trunc('month', current_date) THEN app_gross_total END), 0) AS aktuell,
COALESCE(SUM(CASE WHEN app_invoice_date < date_trunc('month', current_date) THEN app_gross_total END), 0) AS vormonat
FROM app_invoices
WHERE app_invoice_date >= date_trunc('month', current_date) - INTERVAL '1' MONTH
AND app_invoice_date < date_trunc('month', current_date) + INTERVAL '1' MONTH
)
Display Traffic light, unit % – Percent, Higher is better, Green from 0, Yellow from -10. Green from 0 %, yellow between −10 % and 0 %, red below. If the previous month had no revenue, the query returns no value and the KPI shows “No data”.
Frequently asked questions
The KPI shows “No data” although the query returns rows in Data analytics.
The first row contains no column with a number, for example because the sum is NULL or the number comes as text. COALESCE(…, 0) and CAST(… AS DOUBLE) help.
How does a label get below the value?
The label (“offen, brutto” in the picture) is the widget setting label. The Designer currently has no field for it; a connected AI assistant can set it, or it stays empty.
Can the KPI point to a record?
The source Data object is announced but not yet available. Until then, a query with WHERE id = '…' returns the same value.
Does the KPI show the trend versus the previous day?
No. Comparisons are calculated in the query and shown as a traffic light or percentage, see the example above.
Next step
Table: several rows and columns with search, summary row and export.