# How to add a calculated field on the filtered data and use the same in a visualization

**URL:** <https://discuss.elastic.co/t/how-to-add-a-calculated-field-on-the-filtered-data-and-use-the-same-in-a-visualization/198048>\
**Category:** Kibana\
**Created:** [September 4, 2019, 12:55pm UTC](https://discuss.elastic.co/t/how-to-add-a-calculated-field-on-the-filtered-data-and-use-the-same-in-a-visualization/198048 "2019-09-04T12:55:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manish\_Mishra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/manish_mishra/32/45030_2.png) [@Manish\_Mishra](https://discuss.elastic.co/u/Manish_Mishra)\
**Post date:** [September 4, 2019, 12:55pm UTC](https://discuss.elastic.co/t/how-to-add-a-calculated-field-on-the-filtered-data-and-use-the-same-in-a-visualization/198048/1 "2019-09-04T12:55:53Z")

</div>

Hi,

I am trying to analyze some video play data. I have 4 primary columns :  
#1 Video Id  
#2 User Id  
#3 Video Watched (video watched in seconds)  
#4 Video Length (video length in seconds)

I am trying to create a vertical graph with x axis as completion rate bins (Ex : 0-10% completion, 11-20% completion etc.) for which I will have to create a new field 'video watched' divided by 'video length' and,

y axis as the count of videos.

Best!

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [September 6, 2019, 10:22am UTC](https://discuss.elastic.co/t/how-to-add-a-calculated-field-on-the-filtered-data-and-use-the-same-in-a-visualization/198048/2 "2019-09-06T10:22:52Z")

</div>

Hello,

You can achieve this in a line chart, by creating a scripted field that does the division "video\_watched"/"video\_length" and then using that as a histogram with 0.1 intervals (which would equate to 10% intervals if using percentages in the field formatter)

---

<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:** [October 4, 2019, 10:22am UTC](https://discuss.elastic.co/t/how-to-add-a-calculated-field-on-the-filtered-data-and-use-the-same-in-a-visualization/198048/3 "2019-10-04T10:22:59Z")

</div>

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