Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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.

19 Replies
Not applicable
Author

my problem is like this http://community.qlik.com/message/240999

but i need to compute base on the ID

christophebrault
Specialist
Specialist

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

I don't understand this requirement. Can you explain more or share data ?

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

It seems that my data peeks in other rows, i don't know why it works like that.

attached file is what i'm testing..

Not applicable
Author

Hi,

use Previous() to access the last row.

LOAD

     D,

     ID,

     Value,

     Value - Previous( Value ) as Value1

FROM

     Source

ORDER BY

     D;

adhudson
Creator II
Creator II

Hi,

     There are several functions in qlikview to get the values from the previously loaded rows.

     Try out Previous and peek functions. you can find beautiful descriptions from QlikView Help Menu or Press F1.

     Hope this helps.

Regards

Andrew Hudson

Not applicable
Author

thank you for replies

alhough i'm still having problem regarding my data.

I think the problem is because there is a date field. I have attached my .qvw, you can check it out.

Thanks

Not applicable
Author

bump.

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.

Not applicable
Author

Wow thank you very much!

I would try to apply it now to my work. Thanks

christophebrault
Specialist
Specialist

edit : didin't see you had a correct answer before...

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