Trying to Calculate the ratio/percentage in the singlestat panel for *ElasticSearch*

Hello, Everyone
I am using ElasticSearch as my datasource and creating a singlestat panel.
What i want from the panel is to display the ratio of two variables. First, in the metric section i am selecting sum of of one variable and in the other metric the sum of other variable. But i don’t know how to calculate their ratio.
Either help me how to aggregate my result or by writing script on grafana to get desired result.
Kindly help me with this issue.