# Is it possible to create a pie chart from N different fields?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574>\
**Category:** Kibana\
**Created:** [February 26, 2018, 10:59pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574 "2018-02-26T22:59:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![joconner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joconner/32/24360_2.png) [@joconner](https://discuss.elastic.co/u/joconner)\
**Post date:** [February 26, 2018, 10:59pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574/1 "2018-02-26T22:59:57Z")

</div>

I have 3 different durations (times between events) that make up 100% of the total time spent in a process. I want a pie chart to show a slice for each duration (3 slices). My documents have 3 fields, one for each duration.

Unfortunately, the Pie Chart visualization seems to allow summation or counts of a single document field, not different ones. Have I read this correctly? And if so, do you have suggestions for how I can use a pie chart in this situation?

Example docs:

```auto
{
  "id": 1,
  "duration1": 42.3,
  "duration2": 10.4,
  "duration3": 5.3
},
{
  "id": 2,
  "duration1": 35.2,
  "duration2": 8.4,
  "duration3": 3.3
},
{
  "id": 3,
  "duration1": 40.5,
  "duration2": 22.3,
  "duration3": 15.9
}

```

I've considered that maybe I can restructure these documents like this:

```auto
{
  "id": "1a",
  "durationType": "FOO",
  "duration": 42.3
},
{
  "id": "1b",
  "durationType": "BAR",
  "duration": 10.4
},
{
  "id": "1c",
  "durationType": "BAZ",
  "duration": 5.3
}

```

And this would allow me to use a single field `duration` for the pie chart while aggregating on a `durationType` filter. **However, the downside of this method is that it separates the 3 durations across 3 separate sub-documents. This prevents me from filtering out all 3 docs when the duration of one is under or above a specific threshold.** For example, I might need to filter out the 3 docs from the pie chart if the BAZ duration is under 6 seconds. And in this filtering situation, I'd want docs 1a, 1b, and 1c to **not** be included in the pie slices.

Any ideas?

---

<div class="post-metadata">

**Author:** ![vinodr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vinodr/32/28759_2.png) [@vinodr](https://discuss.elastic.co/u/vinodr)\
**Post date:** [February 27, 2018, 3:24pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574/2 "2018-02-27T15:24:27Z")

</div>

You could try a **Split Slices** on **Filters Aggregation** with the following three filters:

 ![Pie%20Chart%20from%20N%20Different%20Fields](https://us1.discourse-cdn.com/elastic/original/3X/c/2/c25a30411b3527b0e8908f62157a08f14acc2d8c.JPG)  
This should give you three Slices in the Pie Chart, each showing the Count of Documents which contain the respective fields: duration1, duration2 and duration3 (assuming that the Metrics chosen for Slice Size is Count)

---

<div class="post-metadata">

**Author:** ![joconner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joconner/32/24360_2.png) [@joconner](https://discuss.elastic.co/u/joconner)\
**Post date:** [February 27, 2018, 6:12pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574/3 "2018-02-27T18:12:57Z")

</div>

Thank you @vinodr for your suggestion. In this example, all documents will have all 3 fields, so your suggestion will show 3 equal slices every time I think.

Also, I'm hoping to show a pie chart showing slices of time amounts, not counts. So I think i need the slice size to be based on a time field, not count.

Thank you for reading and trying to help!

---

<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:** [March 27, 2018, 6:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-create-a-pie-chart-from-n-different-fields/121574/4 "2018-03-27T18:13:58Z")

</div>

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