# Elastic kibana explain method into percentage

**URL:** <https://discuss.elastic.co/t/elastic-kibana-explain-method-into-percentage/241462>\
**Category:** Kibana\
**Created:** [July 16, 2020, 1:02pm UTC](https://discuss.elastic.co/t/elastic-kibana-explain-method-into-percentage/241462 "2020-07-16T13:02:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aretai](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aretai](https://discuss.elastic.co/u/aretai)\
**Post date:** [July 16, 2020, 1:02pm UTC](https://discuss.elastic.co/t/elastic-kibana-explain-method-into-percentage/241462/1 "2020-07-16T13:02:52Z")

</div>

Hi there,

I currently have a search system that displays percentage of found words in the database. I'm thinking of moving to elastic search, but I still want the results to be displayed as percentage. Is it possible? Currently in Kibana I have an explain function that displays for example the "value" : 0.6931471, How can I convert it to percentage to be used in my system?

Thank you for answers

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [August 12, 2020, 10:28am UTC](https://discuss.elastic.co/t/elastic-kibana-explain-method-into-percentage/241462/2 "2020-08-12T10:28:22Z")

</div>

Hi @aretai,  
I tried to solve it with TSVB, but I actually think Vega is the only option here. Here's the screenshot of the similar problem on the sample flights data (Percent of flights delayed in time range (filter ratio)):

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

This is Vega code:

```auto
{
  $schema: https://vega.github.io/schema/vega-lite/v2.json
  data: {
    url: {
      %context%: true
      %timefield%: timestamp
     index: kibana_sample_data_flights
     body: {
            aggs: {
              f: {
                filters: {
                  filters: {
                    delayed: { match_phrase: { FlightDelay: true } }
                    total: { match_all: { } }
                  }
                }
              }
            }
        // Speed up the response by only including aggregation results
        size: 0
      }
    }

    format: {property: "aggregations.f.buckets"}
  }

  mark: text

  transform: [{
    calculate: "datum.delayed.doc_count / datum.total.doc_count",
    as: "percent"
  }]

  encoding: {
    text: {
      field: "percent"
      type: quantitative
      format: ".2%"
    }
    size: { value: 48 }
  }
}

```

I'd suggest to try it yourself with sample data and adjust the code to your needs.  
Let me know if it helps.

Best, Marta

---

<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:** [September 9, 2020, 10:28am UTC](https://discuss.elastic.co/t/elastic-kibana-explain-method-into-percentage/241462/3 "2020-09-09T10:28:22Z")

</div>

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