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: 
AmCh
Creator
Creator

Use of functions

Hello all,
I have imported the following list 'Zeilen_PM'.
From this I wanted to determine the maximum value and then perform calculations within the FOR LOOP using the already calculated maximum value and generate a list.
Here is a simplified representation of a calculation:

 

DIRECTORY;
LOAD Zeilen_PM
FROM
[..]
(ooxml, embedded labels, table is Sheet1);

let vMAX=MAX(Zeilen_PM,1);

For Zahl=0 to 100
DATA:
LOAD
'$(Zahl)'*Zeilen_PM as WE
AutoGenerate 1;
next

 

But it comes to an error message 'Field vMax not found'.

Field not found error

Field 'Zeilen_PM' not found

DATA:
LOAD
'0'*Zeilen_PM as WE
AutoGenerate 1

What is the reason for this error?

Thanks in advance.
Best regards

 

Labels (2)
1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try using dollar expansion for your variable like:

$(Zahl) * $(vMAXas WE

View solution in original post

4 Replies
edwin
Master II
Master II

first, this will not work:  
let vMAX=MAX(Zeilen_PM,1);

you cant use this operation on a variable, you need to determine the max of a field in a table and then let the variable have the value:

 

noconcatenate tmp: LOAD max(Zeilen_PM) as maxZeilen_PM
FROM [..] (ooxml, embedded labels, table is Sheet1);

let vMAX=peek('maxZeilen_PM',0, tmp);

 

 

 

AmCh
Creator
Creator
Author

thank you for your prompt answer.

Here the changed script:

noconcatenate tmp: LOAD max(Zeilen_PM) as maxZeilen_PM
FROM [O:\73_DataSource\201230_Zwischenschritte.xlsx] (ooxml, embedded labels, table is Sheet1);

let vMAX=peek('maxZeilen_PM',0, tmp);

For Zahl=0 to 100
DATA:
LOAD
'$(Zahl)'*vMAX as WE
AutoGenerate 1;
next

The same message still exists:

 

Field not found error

Field 'vMAX' not found

DATA:
LOAD
'0'*vMAX as WE
AutoGenerate 1

Is there anything to change within the loop?

tresesco
MVP
MVP

Try using dollar expansion for your variable like:

$(Zahl) * $(vMAXas WE

AmCh
Creator
Creator
Author

It works perfectly!
Thank you.