Why Doesn’t My Duration Chart Work?

Why Doesn’t My Duration Chart Work?

Use meta.duration, Not result.duration

If you’re trying to build a chart with duration as the metric and it’s not working, then the reason is probably that you’re trying to get values from result.duration. Use meta.duration instead.

Statements encode the result.duration property as a string in ISO 8601 format: e.g., PT59.14S = 59.14 seconds. In contrast, statements keep the value in the meta.duration property as an integer: e.g., 59140 = 59,140 milliseconds. Because meta.duration is a number, you can use it to calculate the heights of columns in a bar chart.

Duration Conversion Factors

If you want to show values in units other than milliseconds, then in Chart Builder, under Data Settings > Metric Scale, enter one of these conversion factors:
  1. 0.001      seconds
  2. 1.66667e-5 minutes
  3. 2.77778e-7 hours
  4. 1.15741e-8 days
In Metric Builder and List Builder, you do it by adding an inline mathematical operation in the title or subtitle: e.g., ${value.metric * 0.001}.

In VQL, you convert duration by adding a stage that performs the needed math: "$addFields": {"metric": {"$multiply": ["$metric", 2.77778e-7]}}.