back to forum.

Topic: How sum(col),col1/col2*100

Topic by
wmj007

2011-09-20
05:22

How sum(col),col1/col2*100

How sum(col),col1/col2*100 etc? thank you!

Reply by
emil

2011-09-20
05:22
You can use javascript for this. Click 'Add transformer' - 'Scripting' - 'Javascript transformer'. It gives you an example and you can change it according to your needs.

Reply by
wmj007

2011-09-20
13:56
thanks,emilCan you give me an example?It example can't clear!

Reply by
wmj007

2011-09-21
05:21
It can do dimensional analysis,example broken line graph? if yes,give me an example,thank you!

Reply by
emil

2011-09-21
05:21
I'm not sure I understand your question completely, but to give an example:

function eval() {
return ((values[0] / values[1]) * 100) ;
}

eval();

Here you have a calculation that is similar to the one you were asking for. 'values[0]' is the first input column, 'values[1]' is the second, etcetera. If you now click 'preview data', you will see your input columns and the new output column with the outcome of the calculation, for example:

1 3 33.33333333333333
1 7 14.285714285714285
5 7 71.42857142857143

In order to do such calculations, you have to ensure that your input columns are numbers and not strings; because if you do "1" + "3" as strings, it will return "13". If you do that with numbers, it will return 4.

Does this help?

Reply by
wmj007

2011-09-21
05:21
yes,thank very much!

function eval() {
return ((values["col1"] / values["col2"]) * 100) ;
}

eval();

it good!

You need to be logged in to participate

In order to post your own comments on this topic, you need to be logged in.

Username:

Log in by clicking the login link at the top of the screen

 

Go back to forum.