SQL Dividing 2 values from 2 queries in CANVAS

Hey @AlfredoC, so you can't do this directly in the SQL but you should be able to accomplish it using the math and string expression functions. Here is a link to the Canvas expression documentation: https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html

Here is another Discuss post that answers a similar question: Kibana Canvas , Calculate percentage using to aggregations

The important bit is:

| essql 
    query="SELECT order_date, customer_gender FROM \"kibana_sample_data_ecommerce\""
    count=10000
| math { 
    string "count(customer_gender)/" 
      {filters group="order_date" ungrouped=true 
       | essql query="SELECT order_date, customer_gender FROM \"kibana_sample_data_ecommerce\""
           count=10000
       | math "count(customer_gender)"
      } 
  }
1 Like