# How to create a visualization for this scenario

**URL:** <https://discuss.elastic.co/t/how-to-create-a-visualization-for-this-scenario/163705>\
**Category:** Kibana\
**Created:** [January 10, 2019, 10:29am UTC](https://discuss.elastic.co/t/how-to-create-a-visualization-for-this-scenario/163705 "2019-01-10T10:29:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srudhi](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Srudhi](https://discuss.elastic.co/u/Srudhi)\
**Post date:** [January 10, 2019, 10:29am UTC](https://discuss.elastic.co/t/how-to-create-a-visualization-for-this-scenario/163705/1 "2019-01-10T10:29:17Z")

</div>

I have a scenario where I wanted to create a widget of top 5 high priority tickets where each  
ticket can have multiple events and a same event can be mapped to a ticket more than once. And if a same event is mapped to a ticket more than once it has to take that as a single count. For eg i have a ticket T1 with events E1,E1 and E2 then the count has to be 2 not 3

{  
"size": 0,

```
"aggs": {
	"sortByPriority": {
		"terms": {
			"field": "priority.keyword",
			"order": {
				"_key": "asc"
			}

		},

		"aggs": {
			"sortByTime": {
				"terms": {
					"field": "dateTime",
					"order": {
						"_key": "desc"
					}
				},
				"aggs": {
					"ticket": {
						"terms": {
							"field": "ticketId.keyword"

						},
						"aggs": {
							"eventByTicket": {
								"terms": {
									"field": "_id"

								},
								"aggs": {
									"top_sales_hits": {
										"top_hits": {

											"_source": {
												"includes": ["eventId", "priority", "dateTime"]
											}

										}
									}
								}
							}
						}
					}

				}
			}
		}
	}
}

```

}

I need to create a donut chart for the same in kibana visualization

---

<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:** [February 7, 2019, 10:29am UTC](https://discuss.elastic.co/t/how-to-create-a-visualization-for-this-scenario/163705/2 "2019-02-07T10:29:20Z")

</div>

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