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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

What's wrong in my FOR ... NEXT ?

------------------------------my script:

Fact_SKU_Price:
load distinct ID
,Brand&' '&Package as Product_Name
,Retail_Price as Retail_Price
resident SKU_Price_temp;

Dim_Product:
load distinct Product_Name as Product
resident Fact_SKU_Price;

FOR i = 0 TO NoOfRows('Product') - 1

LET vProduct = peek('Product', $(i));

LOAD ID
,Retail_Price as '$(vProduct ) '
RESIDENT SKU_Price
where Product = '$(vProduct )';

NEXT i

I want to Anti-Crosstable the price value of every product. In the debug, I saw the value of vProduct is correct in the first loop. But from begining of the second loop, the value of vProduct is always 'NULL'.

But if the FOR...NEXT is simply following,the value of vProduct is always correct in debug :

FOR i = 0 TO NoOfRows('Product') - 1

LET vProduct = peek('Product', $(i));

NEXT i

What's wrong with my script?

2 Replies
sparur
Specialist II
Specialist II

Hello, Jonh.

Why do you use NoOfRows() function for field?

You should use a fieldvaluecount('Product') or NoOfRows('Dim_Product')

Anonymous
Not applicable
Author

Thanks for sparur, using fieldvaluecount('Product') is OK.