# Line chart from field values and sum

**URL:** <https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175>\
**Category:** Kibana\
**Created:** [April 23, 2018, 8:10pm UTC](https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175 "2018-04-23T20:10:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maddy\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maddy_m/32/45638_2.png) [@Maddy\_M](https://discuss.elastic.co/u/Maddy_M)\
**Post date:** [April 23, 2018, 8:10pm UTC](https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175/1 "2018-04-23T20:10:08Z")

</div>

Hi,

I am newbie to ELK and I have able to work on the queries, but need help with Kibana Visualization for line chart value extracted from fields.

Here is the document and I would like to prepare a line chart with 4 lines from values extract from fields (dist,dcs,cap,distltocap) and line sum of all four values and groupby UniqueID. Each document has unique ID with values for these fields. Could you please advise?

{  
"\_index": "intodisk-2017.06.23",  
"\_source": {  
"dist": 76,  
"dcs": 3,  
"cap": 2,  
"distltocap": 1,  
"UniqueID": "8751256",  
"@timestamp": "2017-06-23T19:58:11.195Z",  
"host": "linuxget1",  
"time": "23/06/2017 15:58:10",  
},  
"fields": {  
"@timestamp": [  
1524513491195  
]  
},  
"sort": [  
1524513491195  
]  
}

---

<div class="post-metadata">

**Author:** ![Stacey\_Gammon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stacey_gammon/32/14025_2.png) [@Stacey\_Gammon](https://discuss.elastic.co/u/Stacey_Gammon)\
**Post date:** [April 23, 2018, 8:33pm UTC](https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175/2 "2018-04-23T20:33:08Z")

</div>

> I would like to prepare a line chart with 4 lines from values extract from fields (dist,dcs,cap,distltocap)

You should be able to do this by adding metrics on the Y axis. You will need to select something like, Max, Min, Sum, or average because you could get multiple documents in the same bucket chosen for the x-axis. If there is only a single doc in each bucket, then it shouldn't matter which of these metrics you select.

 ![31%20PM](https://us1.discourse-cdn.com/elastic/original/3X/2/5/250da4c7092ecf77c68fb8e880323ffc466d8c75.jpg)

> and line sum of all four values and groupby UniqueID.

You can create a new field that sums all values by creating a painless scripted field. Something like:

 ![59%20PM](https://us1.discourse-cdn.com/elastic/original/3X/b/5/b592fbfa06b5074e5556609c1bbf8e481fafcbd2.jpg)

---

<div class="post-metadata">

**Author:** ![Maddy\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maddy_m/32/45638_2.png) [@Maddy\_M](https://discuss.elastic.co/u/Maddy_M)\
**Post date:** [May 14, 2018, 3:29pm UTC](https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175/3 "2018-05-14T15:29:11Z")

</div>

Hi,

Thanks for the replay. I am able to use the expression provided and able to plot the values after calculating the sum. Just a question, how can I tag or represent each value with corresponding UniqueID in the chart?

Thanks,  
Maddy

---

<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:** [June 11, 2018, 3:29pm UTC](https://discuss.elastic.co/t/line-chart-from-field-values-and-sum/129175/4 "2018-06-11T15:29:15Z")

</div>

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