How to show percentage and counts (both at the same time) in bar graphs


I am new to Kibana. I am using Kibana 7.4. and I am unable to figure out a way to show percentage and count (both) on every bar of my simple bar graph. I could show either the percentage or the count on the bar chart, but not both together.
There have been some ideas about scripted fields, but I wanted to ask if even now, with Kibana 7.4, that's the only option. If you know of simpler options, please share. If not, any guidance on scripted fields will be much appreciated too!.


Hi @Ssingh12. You can add multiple metrics to the y-axis of any bar chart in the vis editor. What percentage are you trying to display though?

@bargs, I do not want to 'plot' the percentage on the chart. I simply wanted to add it as a label to existing bars of 1st Y axis.
I have done a terms aggregation and need the count of individual terms (as well as need an information in 'label'/'tooltip' what percentage is the count of a term of the total count of all terms together.

I don't believe this is possible at the moment. Pie charts show both counts and percentages by default, but bar charts do not. I also don't know how scripted fields would help, because scripted fields work at the level of individual documents, not aggregations. I'd recommend filing a feature request on our Github repo.

I found this issue in github which asks for exactly this -

Would you know any other way to achieve this.

That's an old issue from before percentages were supported as a display mode in Kibana at all. I don't think it covers the use case where you want to display both the count and the percentage at the same time. You'll have the best luck if you create a new github ticket stating clearly the specific enhancement you need.

@Bargs, I have developed a somewhat better understanding of Kibana since I started on this topic. I read my original topic description and saw that, due to lack of knowledge, I mixed up scripted queries with scripted fields. The question probably is - whether the %age as part of labels may be achieved using scripted queries.

An positive/negative indication on this would give me a huge direction to pursue/ditch this idea.

Appreciate your help all though.

Unless I'm totally misunderstanding, I think what you are asking about is scripted metric aggregation. A script query filters the results but it doesn't aggregate, which you would need to compute a percentage. But, Kibana doesn't support scripted metric aggregations. It would also be overkill to compute percentages in this way. Kibana can already compute the percentage out of the total document count for a given bucket with the data available, it just doesn't make this option available in the UI.

@Bargs, yes, I may be looking for a scripted metric aggregation... Overall, I like your idea of doing it in UI. We may be able to modify opensource to introduce this. I was just a bit wary of disturbing the source, but it appers to be the simplest and fastest option.

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