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: 
qlikconsultant
Creator III
Creator III

Problem with "multiplication" and "if" in the load script

I have the following Code:

Calc_Temp:

Noconcatenate

LOAD

Key as Key,

CountN,

round( rangeavg(

              peek(CountN,,-1),

               peek(CountN,-2),

               peek(CountN,-3),

               peekCountN, -4),

               peek(CountN,-5),

)) as averag5,

round( rangeavg(

              peek(averag5,-1),

               peek(averag5,-2),

               peek(averag5,-3),

               peek(averag5,-4),

               peek(averag5,-5),

)) as avg5avg,

((peek(averag5)+peek(avg5avg))/2) as Finalavg,

num(peek(Finalavg,0))*1.6+ as DValue,

if ((CountN)>peek(DValue,0),peek(averag5,0),CountN) as Final

resident BasicData;

join Calendar;

Everything is working except the lines:

num(peek(Finalavg,0))*1.6+ as DValue,

if ((CountN)>peek(DValue,0),peek(averag5,0),CountN) as Final

There are errors but im out of ideas what it could be?

5 Replies
MayilVahanan

Hi

(peek(averag5)+peek(avg5avg))/2) as Finalavg,

num(peek(Finalavg,0))*1.6+ as DValue,

if ((CountN)>peek(DValue,0),peek(averag5,0),CountN) as Final

In this, you are creating new field named 'Finalavg'. You can't directly use the field name next line. Once the table load only, it create the Field. So only it shows error. Finalavg field is not found Like that..

Same reason for DValue also.

Hope u will understand.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
thomduvi83
Partner - Contributor III
Partner - Contributor III

Not existing on first row will at worst return null, but should not return an error.

What's that "+" after the 1.6, isn't that throwing an error ?

qlikconsultant
Creator III
Creator III
Author

I create the Field averag5 what i use next line. Why should it a problem later?

But if I understand you correctly so I have to create a new table and load the data there. Then I can create this attribute?

qlikconsultant
Creator III
Creator III
Author

"+" was only a copy mistake and didn't throws the error.

Gysbert_Wassenaar

There are two comma's in peek(CountN,,-1). Other than that I don't see anything that would throw an error.

num(peek(Finalavg,0))*1.6+ as DValue,

if ((CountN)>peek(DValue,0),peek(averag5,0),CountN) as Final

Finalavg doesn't have a value on the first row so DValue will always be null. And then the if statement on the next line will always return CountN because the comparison between CountN and a null will return FALSE.


talk is cheap, supply exceeds demand