Store Field Issue in Kibana

Hi,
I am using Kibana with Elastic search. I have different indicators which I have to calculate and then show them in charts. I am facing problem in indicators which themselves depend on other indicators, e.g
I have an indicator name 'test' which is in %age. It will be calculated after calculation of two other indicators i-e "test1" and "test2"
in simple words

`test=(test1/test2)*100

test1 ='elasticsearch field1' + 'elasticsearch field2'

and as for test2

test2 ='elasticsearch field3' + 'elasticsearch field4'

//sum metrics will be use

`Kibana calculates test1 and test2 and also show them in charts, but I don't need to show these indicators to show in charts, I want to show in chart test indicator, When I do this, Kibana returns error that test1 and test2 does not exist,
So it is problem of store field , that It is not storing values in these variables.

Here is code for above explanation

`x =doc['field1'].value + doc['field2'].value

y=doc['field3'].value + doc['field4'].value

z=x/y`

Now When I use 'z' , it gives error, that x and y doesn't exist.

Is there any solution for this