Allow computed values to be used in visualization YML definitions
Release notes
Problem to solve
With Product Analytics, users have many pieces of data and wish to visualize them. They also wish to visualize relationships between them as "computed metrics." That is, a metric that is created by combining two separate metrics using operations like addition, subtraction, division, multiplication, etc.
Cube.dev has support for performing these type of operations in the SQL queries it runs, but this requires updating Cube.dev schemas, which is difficult or sometimes impossible for end-users to do themselves. Users are familiar with using our YML syntax for specifying dashboards and visualizations but are unfamiliar with Cube.dev.
A concrete example of this is if a user has two Cube measures, uniqueUsers
and uniqueSessions
, and wishes to display average sessions per user. They would have to update a Cube.dev schema file to do this, as we currently do in our cube/schema/Sessions.js
file.
Proposal
Allow users to specify computed measures in their YML files for visualizations.
- There are lots of ways to do this. For this first iteration, approach this and find a boring solution.
- Computed values can be computed as inline-only, rather than being given a name to be referenced elsewhere.
- Said another way, writing things like
metricA * metricB
would be sufficient, rather than storing the value ofmetricA * metricB
as a named item that could be used in other visualizations.
- Said another way, writing things like
- Computed values can be scoped to expressions with only a single binary operators with two operands or a single unary operator with one operand per visualization.
- Said another way, only operations that need one (e.g.
!
) or two arguments (e.g.*
,+
,-
,/
) are supported. No need to support complicated expressions combining multiple operations together (e.ga+b/c*d
)
- Said another way, only operations that need one (e.g.
Concept
Concept for what this like might look like is below. This is for inspiration, feel free to choose a different approach during planning & implementation.
{
"version": 1,
"title": "Average Sessions per User",
"type": "SingleStat",
"data": {
"type": "cube_analytics",
"query": {
--> "computedMeasure": ["Sessions.count", DIVISION, "Jitsu.uniqueUsersCount"],
...
}
...
}
Intended users
Feature Usage Metrics
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.