3 Replies Latest reply: Jun 27, 2012 4:10 AM by jagan mohan rao appala

# How to Subtract second value of column A from first value of column B.

I have two columns with 5 rows,

A{1,2,3,4,5} And B{6,7,8,9,10}

I want to subtract 2nd value from column A from 1st value of column B.

(i.e. I want to subtract (n+1)th value from column A from (n)th value of column B.)

So there will be one column with 4 rows, in this case, (6-2 = 4), (7-3 = 4), (8-4 = 4), (9-5 = 4)

(n-1 values in general)

What is the script for this expression?

Can we use an in built function Previous? if yes, how?

Thanks,

Himanshu

• ###### How to Subtract second value of column A from first value of column B.

Min(B)- min(A,2)

or

top (B)_top(A,2)

try out this

• ###### How to Subtract second value of column A from first value of column B.

above(a,1)-b use this expression

• ###### Re: How to Subtract second value of column A from first value of column B.

Hi,

Try this script,

TableName:

PreviousB - A AS NewColumn,

A, B

WHERE Previous(B) <> NULL();

Previous(B) AS PreviousB,

A,

B;

LOAD * INLINE [

A, B

1, 6

2, 7

3, 8

4, 9

5, 10

];

Hope this helps you.

Regards,

Jagan.