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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Simple in excel, don't know how to do it in QlikView Load Script

Hi!.How can I make this to work in load script?

I have this in one table

ref

1

6

2

8

7

I need to load new table "calc" this way

calc

Start value, Same value as in Ref = 1

Current ref value/previos calc value 6/1=6

Current ref value/previos calc value 2/6=0.33

Current ref value/previos calc value 8/0.33=24.24

Current ref value/previos calc value 7/24.24=0.28


So new calc table must be like this

calc

1

6

0.33

24.24

0.28

Any help will be preciated.

Thanks in advsance

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I gotcha.  Here take a look at this.

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Ref/Previous(Ref) as Calc

or Ref/Peek(Ref) as Calc

Anonymous
Not applicable
Author

Thanks Wallo!

Previous and Peek does not work, I get "field not found", and O think this is because I'm creating "calc" value

Here's the code I wrote

tmpTableCalcWithPrevious:

LOAD *,

If(ref = 1, 1, ref/Previous(calc)) as calc

Resident tmpTableRef;

tmpTableWithPeek:

LOAD *,

If(ref = 1, 1, ref/Peek(calc)) as calc

Resident tmpTableRef;

Any clue?

Anonymous
Not applicable
Author

This works for me.

Anonymous
Not applicable
Author

Thanks again Wallo!! Your code works, but the calculation I need is different.

You're doing ref/Previous(ref) as calc

I need (but don't know hou to do it) ref/Previous(calc) as calc

Anonymous
Not applicable
Author

I gotcha.  Here take a look at this.

Anonymous
Not applicable
Author

Awesome. Thanks a lot!!!