You can find a similar request here and in essence, the trick is to split your SQL into two essql
queries and divide them. Using Canvas from Kibana 7.6 and the sample Flights dataset to get the percentage of canceled trips:
filters
| essql
query="SELECT count(1) as cnt FROM \"kibana_sample_data_flights\" WHERE Cancelled = true"
| math {string "cnt/" {filters | essql query="SELECT count(1) as cnt FROM \"kibana_sample_data_flights\"" | math "cnt" }}
| formatnumber "0%"
| render
Cheers