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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

For Each - Loop Issue

Hi everyone!
I have such code:

 

Spreadsheet_List:
Load * Inline
[
	Spreadsheet_ID, Spreadsheet_Key,      Spreadsheet_Name
	1,  			Test 1, 			  Salesforce
	2,  			Test_2, 			  HR

];

For Each a in FieldValueList('Spreadsheet_ID')

trace Spreadsheet_ID  $(a);

	Let vSpreadsheet_Key  = Peek('Spreadsheet_Key',$(a),'Spreadsheet_List');
	Let vSpreadsheet_Name = Peek('Spreadsheet_Name',$(a),'Spreadsheet_List');

	
	Trace Spreadsheet_Key $(vSpreadsheet_Key)  Spreadsheet_Name $(vSpreadsheet_Name) ;

Next a

 

 

 

 

 And for some reason this loop does not go through" Spreadsheet_List"  table row by row. Instead  it is simply jump into last row  and omit first one. Ignoring "Salesforce" data and starting from "HR" data.

Peony_0-1681763972713.png
Could you please help to figure out what's wrong with this code? Why it does not goes all rows in a table?

 

 

Labels (2)
1 Solution

Accepted Solutions
Kushal_Chawda
MVP
MVP

@Peony  when you use peek, record reference starts with 0. Here you are passing Id from 1, so in your variable subtract 1

Let vSpreadsheet_Key = Peek('Spreadsheet_Key',$(a)-1,'Spreadsheet_List');
Let vSpreadsheet_Name = Peek('Spreadsheet_Name',$(a)-1,'Spreadsheet_List');

View solution in original post

2 Replies
Kushal_Chawda
MVP
MVP

@Peony  when you use peek, record reference starts with 0. Here you are passing Id from 1, so in your variable subtract 1

Let vSpreadsheet_Key = Peek('Spreadsheet_Key',$(a)-1,'Spreadsheet_List');
Let vSpreadsheet_Name = Peek('Spreadsheet_Name',$(a)-1,'Spreadsheet_List');

Peony
Creator III
Creator III
Author

Indeed! @Kushal_Chawda  Thank you for help!