Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

3 Replies
SunilChauhan
Champion
Champion

Min(B)- min(A,2)

or

top (B)_top(A,2)

try out this

Sunil Chauhan
perumal_41
Partner - Specialist II
Partner - Specialist II

above(a,1)-b use this expression

jagan
Luminary Alumni
Luminary Alumni

Hi,

Try this script,

TableName:

LOAD

    PreviousB - A AS NewColumn,

    A, B

WHERE Previous(B) <> NULL();

LOAD

    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.