Canvas - Render a metric generated based in other two metrics

I am looking to have configure a metric in Canvas to cover the following scenario: Calculate the total amount of sales all time divided by total sales in specific timeframe (i.e. first 3 months). I see within TSVB I can create one metric for all time and one other for specific timeframe. However, I am unable to put both together to calculate required metric. Is there any way I can do that to render into Canvas, using Kibana Visualizations or Timelion?

In canvas you can do something like this:

filters
| essql query="SELECT sum(bytes) as bytes FROM \"kibana_sample_data_logs\""
| math {string {filters | essql query="SELECT sum(bytes) as bytes FROM \"kibana_sample_data_logs\" WHERE timestamp > (CURRENT_DATE - INTERVAL 1 DAY)" | getCell} " / bytes"}
| metric "Ratio"

It's fetching one data point using essql, then executing the math function on the result with the math expression being constructed using the result of a second essql call containing the other data point.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.