Scripted fields need to calculate percentage

Hi
I am trying to display the difference between 2 values eg: Plan spend versus Actual spend and Percentage of spend.

  1. doc['PLAN-EXP'].value - doc['ACT-EXP'].value
    2.(doc['PLAN-EXP'].value - doc['ACT-EXP'].value)/sum(doc['ACT-EXP'].value)
  2. (doc['PLAN-EXP'].value - doc['ACT-EXP'].value)/NAME.value)

Scripted Field 1 works but 2 & 3 does not work.

Or i need to some how access aggregation field here
{
"query": {"match_all": {}},
"aggs": {
"NAME": {
"sum": {
"field": "ACT-EXP"
}
}
},

pls help ...thanks

Hi,

You might want to try using Timelion for this type of charting.

great thanks for the tips will try it out. cheers kumar