# Visual Builder : compute and display a ratio

**URL:** https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836
**Category:** Kibana
**Created:** [April 20, 2018, 8:51am UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836 "2018-04-20T08:51:37Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![geoffroya](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoffroya](https://discuss.elastic.co/u/geoffroya)
#### Post date: [April 20, 2018, 8:51am UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836/1 "2018-04-20T08:51:38Z")

</div>

Hi  
I'm trying to use Visual Builder to compute a ratio, on a given time period.  
I use the log sample data ([https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz](https://download.elastic.co/demos/kibana/gettingstarted/logs.jsonl.gz)).

I want to display the ratio of 404 error code among all request, in the selected period.  
Here's what I do:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/6/169256c8efd310406751459a884f5eaa7bb9fa09.png)  
On period: ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/2/028d64997f45402225a37db64bf24ce31333f034.png)

And I get the following graphic:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/3/037fe8c9eb512461dbfd3be24040eb65e170cbe6.png)

but when looking the metric tab:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/e/7e4aa09e312a98bf2bc88fee12b39ccaa84bbab2.png)

What's wrong in what I did?

Best regards

Geoff.

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [April 20, 2018, 2:41pm UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836/2 "2018-04-20T14:41:29Z")

</div>

`Metric`, `Top N`, `Guage`, and `Markdown` only show values for the last bucket in the date histogram. In your example, the last bucket has a value of zero. There is a lot of user confusion about where the values for `Metric` are getting pulled from. There is an open Pull Request that [adds a new setting that controls the time range used for matching documents](https://github.com/elastic/kibana/pull/15760).

If you want to display the average filter ratio for the entire timerange, you will have to use a parent aggregation to keep a moving average. Then the last bucket will contain the metric that you are expecting.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/6/161a3994ce0fdb22b026b860cf955a1a12e3230e.png)

---

<div class="post-metadata">

### Author: ![geoffroya](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@geoffroya](https://discuss.elastic.co/u/geoffroya)
#### Post date: [April 23, 2018, 5:40am UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836/3 "2018-04-23T05:40:01Z")

</div>

Thank you for your answer. I figured out something like that but used the last « average » in the list. What is the difference with the moving average ?

---

<div class="post-metadata">

### Author: ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)
#### Post date: [April 23, 2018, 3:00pm UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836/4 "2018-04-23T15:00:44Z")

</div>

Bucket aggregations divide documents in buckets.  
Metric aggregations calculate a value for all of the documents in a single bucket  
Pipeline aggregations work on the outputs produced from other aggregations rather than raw documents.

[average](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-metrics-avg-aggregation.html). Metric aggregation that computes the average for all documents in a single bucket.

[Moving average](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-movavg-aggregation.html) pipeline aggregation that computes the moving average of the output of another Metric aggregation .

[average bucket](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html) A sibling pipeline aggregation which calculates the (mean) average value of a specified metric in a sibling aggregation

---

<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: [May 21, 2018, 3:00pm UTC](https://discuss.elastic.co/t/visual-builder-compute-and-display-a-ratio/128836/5 "2018-05-21T15:00:53Z")

</div>

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