Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Getting the previous row and calculate.

Hello and Good Day, I'm currently new in QlikView and I say this is one powerful B.I Tool.

I'm still learning and I need to solve something..

I have a table

DIDValueValue1
D112000 0
D213000 1000
D322000 0
D421500 -500
D52500-1000
D631000..

I need to compute for Value1 depending on the ID.

The computation is d2-d1, d4-d3, d5-d4

I find it hard to explain, but I just need to compute for Value1 depending on the next Value.

Thank you and Good Day.

P.S This is for scripting Thank you.

1 Solution

Accepted Solutions
Not applicable
Author

Hello,

from

if([Plate Number] = Peek([Plate Number]), [Odometer Reading] - Peek([Odometer Reading],0)) as peek

why Peek([Odometer Reading],0))?

Do you really want substract the first value from the table in every row?

left join(A)

LOAD

    Date,

    Time,

    if([Plate Number] = Previous([Plate Number]), [Odometer Reading] - Previous([Odometer Reading])) as new_peek

Resident

    A

Order by Date, Time;

I have an expample enclosed.

View solution in original post

19 Replies
christophebrault
Specialist
Specialist

Hi,

I d'ont really understand your need.

How are your data when you load it, and what do you expect to do in the script exactly ?

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable
Author

it is from excel file. i loaded it.. and it has a lot of sheets.. so there is a for loop inside..

I have a field I need to compute. As I have said above, the results should be like this:

ID          Value     Value1

1           1000          0

1            2000      1000

1             500          -1500

2            100          0

2             200         100

perumal_41
Partner - Specialist II
Partner - Specialist II

Hi,

Try this  expression  in Value

above([Value])-[Value]

use this expression ,u get result

Not applicable
Author

Hi, I will try this in the expression, but I prefer it in the script

christophebrault
Specialist
Specialist

You can use this :

If(Peek(ID)=ID,

     Value-Peek(Value),0) as Value1,

Make sure your data are ordered by ID.

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable
Author

I will try this one, can you give me an example if possible? thank you

Not applicable
Author

I tried your computation, yes it is working but the first value should be the one with the '-'

Not applicable
Author

bump.

Not applicable
Author

bump