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: 
mahmad
Contributor II
Contributor II

Use variables in for loop

Hello,

I'd like to loop over a table of values created in the data load editor, and use the values in the region to dynamically update the bolded text below. I'm not quite sure of the syntax/how to use vContent. Any help is much appreciated! Thanks.

 

vRegions:
LOAD * INLINE [
Region
Europe
Brazil
];

For i = 0 to NoOfRows('vRegions') - 1
let vContent = peek('Region',$(i),'vRegions') ;

Left Join (Table1)
LOAD DISTINCT
%ID, 
Min([Year]) AS [Min Year Europe],
Resident Table2

Where WildMatch([Region],'*Europe*')

Group By %ID;

next i;

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Something like this:

For i = 0 to NoOfRows('vRegions') - 1
	Let vContent = peek('Region', i, 'vRegions') ;

	Left Join (Table1)
	LOAD DISTINCT
		%ID, 
		Min([Year]) AS [Min Year $(vContent)],
		Resident Table2
	Where WildMatch([Region],'*$(vContent)*')
	Group By %ID;

Next i
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Something like this:

For i = 0 to NoOfRows('vRegions') - 1
	Let vContent = peek('Region', i, 'vRegions') ;

	Left Join (Table1)
	LOAD DISTINCT
		%ID, 
		Min([Year]) AS [Min Year $(vContent)],
		Resident Table2
	Where WildMatch([Region],'*$(vContent)*')
	Group By %ID;

Next i
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
mahmad
Contributor II
Contributor II
Author

Perfect - thanks!