# Custom Sort in BAR Charts

**URL:** <https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225>\
**Category:** Kibana\
**Created:** [July 15, 2020, 5:58am UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225 "2020-07-15T05:58:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikramnr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikramnr/32/66065_2.png) [@vikramnr](https://discuss.elastic.co/u/vikramnr)\
**Post date:** [July 15, 2020, 5:58am UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225/1 "2020-07-15T05:58:32Z")

</div>

As title suggest, I'm trying to understand if there any ways to sort bars charts,

Say if I have Critical, High, Medium & Low and if I try alphabetical descending or ascending I'm not achieving this order. Any help would be appreciated. Thanks 🙂

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [July 21, 2020, 1:24pm UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225/2 "2020-07-21T13:24:48Z")

</div>

Hi

Could you provide some more details. maybe a screen containing you visualization, sorting bar charts bars alphabetically should work

 ![Visualize_-_Elastic](https://us1.discourse-cdn.com/elastic/original/3X/2/e/2e7528efdcc7dc9f1fb63a466c8d9c3028c7e05c.png)

Thx and best,  
Matthias

---

<div class="post-metadata">

**Author:** ![vikramnr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vikramnr/32/66065_2.png) [@vikramnr](https://discuss.elastic.co/u/vikramnr)\
**Post date:** [July 22, 2020, 4:28am UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225/3 "2020-07-22T04:28:42Z")

</div>

Thanks Matw. My requirement was sort in the below order using terms.

1. Critical
2. High
3. Medium
4. Low  
But as you can see this will not be in alphabetical order.

I found two ways to achieve this and one is by selecting Aggregation as Filters and filtering in that particular order which I want.

And second one is assigned weight to data based by sorting preference and created scripted field for it. Then use the new scripted field in aggregations to sort it.

Critical -\> 256  
High -\> 128  
Medium -\> 16  
Low -\> 4

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [July 22, 2020, 4:41am UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225/4 "2020-07-22T04:41:21Z")

</div>

Thx for sharing you solution! I that you wanted to share alphabetically, but now it makes sense.

---

<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:** [August 19, 2020, 4:41am UTC](https://discuss.elastic.co/t/custom-sort-in-bar-charts/241225/5 "2020-08-19T04:41:28Z")

</div>

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