# Plot grouped and normalized values on bar chart?

**URL:** <https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087>\
**Category:** Kibana\
**Created:** [September 18, 2020, 10:36am UTC](https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087 "2020-09-18T10:36:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiclasK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niclask/32/47189_2.png) [@NiclasK](https://discuss.elastic.co/u/NiclasK)\
**Post date:** [September 18, 2020, 10:36am UTC](https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087/1 "2020-09-18T10:36:22Z")

</div>

Hi,

I collect the exit status for sessions reported by many IOT-devices. To get an overview, I would like to group a few of the statuses and then plot them on a bar chart. On the X axis I want to have the SW version the IOT devices are running and then use stacked bars to show 3 categories of exit statuses. Since there wil be many more statuses for older releases I would like to normalize the count with the total number of sessions for each SW version. That would give me a value between 0 and 100% for all SW version.

An example with some data:  
exit statuses for successful:

- Finished
- MaintenanceFinished

exit status for when the user has affected the session:

- Aborted
- Postponed

Exit statuses for failur:

- Timeout
- Error
- Crash

I want to this:  
SUM(COUNT(status == Finished), Count(status = MaintenanceFinished)) / COUNT(status)  
SUM(COUNT(status == Aborted), Count(status = Postponed)) / COUNT(status)  
SUM(COUNT(status == Timeout), Count(status = Error), Count(status = Crash)) / COUNT(status)  
plot that in a stacked bar chart and then split by SW version.

How can do that?

---

<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:** [October 12, 2020, 10:33am UTC](https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087/2 "2020-10-12T10:33:16Z")

</div>

Hi @NiclasK,

sorry for the late reply. Did you manage to solve your problem?

---

<div class="post-metadata">

**Author:** ![NiclasK](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/niclask/32/47189_2.png) [@NiclasK](https://discuss.elastic.co/u/NiclasK)\
**Post date:** [October 12, 2020, 10:49pm UTC](https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087/3 "2020-10-12T22:49:18Z")

</div>

Yes, I ended up creating a scripted field that categorize the statuses and then I plot that.

---

<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:** [November 9, 2020, 10:49pm UTC](https://discuss.elastic.co/t/plot-grouped-and-normalized-values-on-bar-chart/249087/4 "2020-11-09T22:49:25Z")

</div>

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