Skip to main content

KPI Arrows

Say you would like to show a graphical indication of a KPI movement on a dashboard.

There are couple ways in Cluvio to do this:

1. Use a Number chart with delta indicators

SELECT 1, SUM(metric) WHERE {timestamp_column=timerange}
UNION ALL
SELECT 2, SUM(metrics) WHERE {timestamp_column=timerange_previous}
ORDER BY 1

image-500image-500

This automatically shows a delta up/down as red/green (or reverse with the option "Down is good" - like on the delays above)

The timerange_previous helps in case you want to compare a user-selected timerange period with the same duration before.

The first column in the query (1/2) above is there only to guarantee the sorting as UNION in SQL would not guarantee the order. This would be by default not displayed on the chart.

2. Use a conditional in SQL query and render unicode characters / emoji

SELECT CASE WHEN COUNT(1) > 5000 THEN '👍' ELSE '👎' END
FROM airports

image-300image-300

3. Use a conditional in SQL query and render as image with HTML format

The Number and Table charts support HTML rendering, and this can be used to display images, here for instance as SVG produced directly from the query. You can of course simply point the src to a URL of an image.

SELECT CASE WHEN COUNT(1) > 5000
THEN '<img width = "25%" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij4KICA8Y2lyY2xlIGN4PSI5IiBjeT0iOSIgcj0iOCIgZmlsbD0iIzI5OUY1RSIgZmlsbC1ydWxlPSJldmVub2RkIi8+Cjwvc3ZnPgo="/>'
ELSE '<img width = "25%" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxOCIgaGVpZ2h0PSIxOCIgdmlld0JveD0iMCAwIDE4IDE4Ij4KICA8Y2lyY2xlIGN4PSI5IiBjeT0iOSIgcj0iOCIgZmlsbD0iI0ZGQjgwMCIgZmlsbC1ydWxlPSJldmVub2RkIi8+Cjwvc3ZnPgo="/>'
END
FROM airports

image-500image-500