# Is it possible to calculate a value from each document and graph it Visual Builder?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419>\
**Category:** Kibana\
**Created:** [April 17, 2018, 7:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419 "2018-04-17T19:13:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamthealex](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@iamthealex](https://discuss.elastic.co/u/iamthealex)\
**Post date:** [April 17, 2018, 7:13pm UTC](https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419/1 "2018-04-17T19:13:08Z")

</div>

The query below gives me back a series of computed values.  
I would like to plot those values in Kibana.  
I think I should be able to do this in Visual Builder, but I'm stumped.  
There is a calculation aggregation, but it needs an aggregation as input.  
I don't have an aggregation, I have a series of documents.

GET /log-lines\*/\_search  
{  
"query": {  
"bool": {  
"must": [  
{"match": { "server": "[large.pod2.cache2.yyz.cdx-test.example.com](http://large.pod2.cache2.yyz.cdx-test.example.com)" } }  
]  
}  
},  
"size" : 0,  
"script\_fields": {  
"lag\_seconds" : {  
"script" : {  
"lang": "painless",  
"source" : "int lag = doc['ls-timestamp'].date.millisOfDay - doc['@timestamp'].date.millisOfDay; return ((lag \< 0) ? lag + 1000 : lag) / 1000;"  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [April 17, 2018, 9:16pm UTC](https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419/2 "2018-04-17T21:16:00Z")

</div>

I don't believe this is currently possible, sorry!

---

<div class="post-metadata">

**Author:** ![iamthealex](https://avatars.discourse-cdn.com/v4/letter/i/e9c0ed/32.png) [@iamthealex](https://discuss.elastic.co/u/iamthealex)\
**Post date:** [April 19, 2018, 2:30pm UTC](https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419/3 "2018-04-19T14:30:35Z")

</div>

I had thought the Visual Builder could do anything timelion could do, but clearly not.  
Doing the subtraction should be do-able in timelion I think -- though I haven't tried it yet.

I also changed the title to emphasize this is not a "Kibana scripted field" I'm asking about.  
I'm asking about computing a value for each record (that is computable from the data in each record).

---

<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:** [May 17, 2018, 2:30pm UTC](https://discuss.elastic.co/t/is-it-possible-to-calculate-a-value-from-each-document-and-graph-it-visual-builder/128419/4 "2018-05-17T14:30:45Z")

</div>

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