# I have a use case related to Cumulative Flow Diagram

**URL:** <https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015>\
**Category:** Kibana\
**Created:** [June 25, 2021, 6:08am UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015 "2021-06-25T06:08:36Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![aswanth\_jabba](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@aswanth\_jabba](https://discuss.elastic.co/u/aswanth_jabba)\
**Post date:** [June 25, 2021, 6:08am UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/1 "2021-06-25T06:08:36Z")

</div>

Hi all,

I am trying to build a Cumulative Flow Diagram, you can have a look at this

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

I will try to explain how we can view this chart, We have 8 **Ready** Stories on 10 June and 3 **Work in Progress** , we can see that the area under **Ready** stories are decreasing, the ready state stories are actually shifting through the different states and end up in **Completed** state

you can watch this video : [Cumulative Flow Diagram (CFD) Explained in Two Minutes - YouTube](https://www.youtube.com/watch?v=eo2uv8avEsU)

And We have the data in this format to work with

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/8/f83abdf9490cfb1e7b7b6958211b40c86d8f0080.png)

Every time when we change the state of a workitem, the data is added to the index

I was trying to use cumulative sum but not that successful, The area under every state just adds up, something like this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/2/92488e1c542d2dae2ec952702c86ba44a56f6874.png)

I am not really sure that if we can achieve this in Kibana, Please suggest anything if this is possible.

---

<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:** [June 25, 2021, 3:18pm UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/2 "2021-06-25T15:18:59Z")

</div>

I understand that you want to take each `workitem` entity and visualize the change in status overall, but your data format requires transformation to do that. To visualize this in Kibana, I would recommend that you transform your data so that you have a multiple summary documents for each timestamp that you care about. Then you can build a stacked area chart using a Terms aggregation + Date Histogram aggregation on top of the summarized data.

You could use the [ES Transforms](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html) feature to accomplish the summarization for you, or you may be able to accomplish this using [Vega](https://www.elastic.co/guide/en/kibana/current/vega.html) which is the most powerful tool in Kibana.

---

<div class="post-metadata">

**Author:** ![aswanth\_jabba](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@aswanth\_jabba](https://discuss.elastic.co/u/aswanth_jabba)\
**Post date:** [June 25, 2021, 7:08pm UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/3 "2021-06-25T19:08:21Z")

</div>

Hi wylie,

Hope you're doing well,

I just want to clarify one more thing, now I understand that I have to transform the data but I am not really sure that how should the output summarized data should look like.

A small example data could really help me.

I want this to be achieved in certain scenario **:** suppose if there are 4 `completed` states and 3 `Ready` states on 15th June, the next day we shift 1 `workitem` from `ready` state to `completed` state, now we should be seeing 2 in `Ready` state and 5 in `completed` state on 16th June.

And one more scenario can be like if no shifts happens the states remain same with the previous date.

I Believe we have to Transform the data in a way to fit these scenario's right ?

Thanks,  
Aswanth.

---

<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:** [June 25, 2021, 7:27pm UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/4 "2021-06-25T19:27:26Z")

</div>

You need to implement exactly the logic you're describing in code somewhere, whether it's using Vega, Transforms, or an external script that performs the summary. If your goal is to visualize this using Kibana's built-in area charts, then the data format you'll need is something like this:

```auto
{ timestamp: 1, status: 'completed', count: 4 }
{ timestamp: 1, status: 'ready', count: 2 }
{ timestamp: 2, status: 'completed', count: 1 }
{ timestamp: 2, status: 'ready', count: 6 }

```

Notice that in my example above, I've repeated _all_ the status summaries multiple times for each timestamp interval. This might require some complex scripting to achieve.

---

<div class="post-metadata">

**Author:** ![aswanth\_jabba](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@aswanth\_jabba](https://discuss.elastic.co/u/aswanth_jabba)\
**Post date:** [June 25, 2021, 7:32pm UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/5 "2021-06-25T19:32:00Z")

</div>

Hi Wylie,

Thank you so much for helping me sort out everything !!  
I really appreciate it ! 😁

---

<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:** [July 23, 2021, 7:32pm UTC](https://discuss.elastic.co/t/i-have-a-use-case-related-to-cumulative-flow-diagram/277015/6 "2021-07-23T19:32:09Z")

</div>

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