# Ratio per Client

**URL:** <https://discuss.elastic.co/t/ratio-per-client/89776>\
**Category:** Elasticsearch\
**Created:** [June 16, 2017, 9:24pm UTC](https://discuss.elastic.co/t/ratio-per-client/89776 "2017-06-16T21:24:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinuja1](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@Vinuja1](https://discuss.elastic.co/u/Vinuja1)\
**Post date:** [June 16, 2017, 9:24pm UTC](https://discuss.elastic.co/t/ratio-per-client/89776/1 "2017-06-16T21:24:49Z")

</div>

Hello,

In order to have the ratio Demand Done /Total Demand per provider, I have looked at the bucket aggregations.  
Therefore, I have two question :

1- Can someone, help me for the aggregation script? I tried the script below but It don't work.  
2- How can I manage to have the result of the ratio per provider in Kibana?

Thank you for the help.

```auto
> POST logs-/hr/_search
> {
> "size": 0,
> "aggs": {
> "ratio_per_provider": {
> "terms": {
> "field": "provider.keyword",
> "size": 10
> },
> "aggs": {
> "nb_demand": {
> "value_count": {
> "field": "DemandId.keyword"
> }
> },
> "nb_executedDemand": {
> "filter": {
> "term": {
> "Executed": "TRUE"
> }
> },
> "aggs": {
> "exedemand": {
> "value_count": {
> "field": "DemandId.keyword"
> }
> }
> }
> },
> "ratio-percentage": {
> "bucket_script": {
> "buckets_path": {
> "tExeDemand": "nb_executedDemand>exedemand",
> "totalDemand": "nb_demand"
> },
> "script": "params.tExeDemand / params.totalDemand * 100"
> }
> }
> }
> }
> }
> }

```

---

<div class="post-metadata">

**Author:** ![Vinuja1](https://avatars.discourse-cdn.com/v4/letter/v/c57346/32.png) [@Vinuja1](https://discuss.elastic.co/u/Vinuja1)\
**Post date:** [June 19, 2017, 12:22pm UTC](https://discuss.elastic.co/t/ratio-per-client/89776/2 "2017-06-19T12:22:55Z")

</div>

can someone help me on this issue please?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [June 20, 2017, 9:27pm UTC](https://discuss.elastic.co/t/ratio-per-client/89776/3 "2017-06-20T21:27:19Z")

</div>

What error did you get? Skimming the agg, your syntax looks correct (but I may be missing something)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 18, 2017, 9:27pm UTC](https://discuss.elastic.co/t/ratio-per-client/89776/4 "2017-07-18T21:27:54Z")

</div>

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