# Organize Weekly Bar Graph by correct day order

**URL:** <https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932>\
**Category:** Kibana\
**Created:** [January 29, 2020, 1:32am UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932 "2020-01-29T01:32:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesyone](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jamesyone](https://discuss.elastic.co/u/jamesyone)\
**Post date:** [January 29, 2020, 1:32am UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932/1 "2020-01-29T01:32:05Z")

</div>

Hi,

I currently created a weekly bar graph with the following scripted field :

LocalDateTime.ofInstant(Instant.ofEpochMilli(doc['xxx'].value.millis),ZoneId.of('Asia/Tokyo')).getDayOfWeek()

and the graph looks something like this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/7/57c1d0de0cd56ba268409a1e6745e320b6123b25.png)

But I am trying to make it where it is organized into the week order. ( E.G. Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday)

Is there a way to make it like that while keeping the time zone to tokyo? Thanks

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [January 29, 2020, 2:51pm UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932/2 "2020-01-29T14:51:03Z")

</div>

There isn't a way to do this exactly, because Kibana doesn't know anything except that these are words that are sorted alphabetically or by another metric.

However, have you considered using the date histogram aggregation instead of the Terms aggregation? If you use a custom timezone and date formatter (in Kibana Advanced Settings, or on the date field in your index pattern) you could show days of the week.

---

<div class="post-metadata">

**Author:** ![jamesyone](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jamesyone](https://discuss.elastic.co/u/jamesyone)\
**Post date:** [February 17, 2020, 1:30am UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932/3 "2020-02-17T01:30:05Z")

</div>

Hi Wylie,

Would I have to create a new scripted field for that?

James

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [February 17, 2020, 5:19pm UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932/4 "2020-02-17T17:19:37Z")

</div>

Date formatters are assigned to a field in your index pattern- it could be scripted, or it could be the original field. If it helps you organize, then it could be useful to create an `alias` field in your index mapping or to create a scripted field.

---

<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 16, 2020, 5:19pm UTC](https://discuss.elastic.co/t/organize-weekly-bar-graph-by-correct-day-order/216932/5 "2020-03-16T17:19:41Z")

</div>

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