# Need to create a bar graph for customers who are having sales less than previous month

**URL:** <https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329>\
**Category:** Kibana\
**Tags:** lens, visualisation\
**Created:** [March 23, 2023, 9:28am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329 "2023-03-23T09:28:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abj\_Ins](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Abj\_Ins](https://discuss.elastic.co/u/Abj_Ins)\
**Post date:** [March 23, 2023, 9:28am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/1 "2023-03-23T09:28:19Z")

</div>

Hi Team,

Need to create a bar graph for customers who are having sales less than previous month. Here we need departments on X-axis.

Thanks.

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [March 23, 2023, 5:07pm UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/2 "2023-03-23T17:07:22Z")

</div>

Hi @Abj_Ins,

Are you able to share what your data looks like?

---

<div class="post-metadata">

**Author:** ![Abj\_Ins](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Abj\_Ins](https://discuss.elastic.co/u/Abj_Ins)\
**Post date:** [March 24, 2023, 6:06am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/3 "2023-03-24T06:06:54Z")

</div>

Thanks @carly.richmond for the response, here is the sample data for your reference.

| Department Code | Sales | Date |
| --- | --- | --- |
| 10 | 32 | 21/03/2023 |
| 10 | 12 | 22/03/2023 |
| 20 | 56 | 20/03/2023 |
| 10 | 67 | 23/03/2023 |
| 30 | 98 | 19/03/2023 |
| 20 | 43 | 14/03/2023 |
| 20 | 65 | 18/03/2023 |
| 30 | 98 | 19/03/2023 |
| 30 | 10 | 17/03/2023 |
| 10 | 89 | 21/02/2023 |
| 10 | 98 | 22/02/2023 |
| 20 | 87 | 20/02/2023 |
| 10 | 21 | 23/02/2023 |
| 30 | 14 | 19/02/2023 |
| 20 | 21 | 14/02/2023 |
| 20 | 87 | 18/02/2023 |
| 30 | 43 | 19/02/2023 |
| 30 | 44 | 17/02/2023 |

Thanks.

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [March 24, 2023, 8:42am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/4 "2023-03-24T08:42:43Z")

</div>

I would suggest in this case a dashboard with a couple of panels in a dashboard:

- a first panel to see the trend of sales for all departments
- a second panel with a breakdown metrics by department with a ratio value and dynamic coloring by value

Here's a simple example I've put together (in your case departments can be used in place of categories here):

 ![Screenshot 2023-03-24 at 09.37.31](https://us1.discourse-cdn.com/elastic/original/3X/0/4/04f70069e5af9f0c62c01e0a3402f6e2ae5e2d06.png)

Note the fixed time range on the metric to make sure to always apply 1 month to it.

As for the metric configuration:

 ![Screenshot 2023-03-24 at 09.39.37](https://us1.discourse-cdn.com/elastic/original/3X/1/c/1cc01da8e7c0acd5de6a9577f704fe1313ebb68c.png)

For the `Current / Prev month` I've used a formula with a shift: `count() / count(shift='1m')` (but you might consider also monthly revenues (still using shift, but use the operation you prefer in place of `count()`).

As for the coloring, I've set 3 stops:

- `> 1` green for ok
- `0.8 < x < 1` yellow for not so ok
- `< 0.8` red

 ![Screenshot 2023-03-24 at 09.39.45](https://us1.discourse-cdn.com/elastic/original/3X/7/2/721bb67b4a8114c0de059552f05e26a5e3e50e0b.png)

---

<div class="post-metadata">

**Author:** ![Abj\_Ins](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@Abj\_Ins](https://discuss.elastic.co/u/Abj_Ins)\
**Post date:** [March 24, 2023, 10:04am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/5 "2023-03-24T10:04:46Z")

</div>

Thanks @Marco_Liberati for your quick response.

---

<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:** [April 21, 2023, 10:05am UTC](https://discuss.elastic.co/t/need-to-create-a-bar-graph-for-customers-who-are-having-sales-less-than-previous-month/328329/6 "2023-04-21T10:05:18Z")

</div>

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