Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Looping through script based on a field

Hi Guys

I have a table with multiple fields which i use for calculations.

For example lets say one of the fields were called Language and there were 5 different languages in the Languages field.

I need to perform different calculations for the different languages in the Language field.

My question is - Is there a way to maybe loop through the script for each language in the Lanugauge field and then store as a qvd??

If so, then i would then just call each qvd seperately and then perform the necessary calculations.

Any help would be appreciated.

Regards,

Magen

3 Replies
alexandros17
Partner - Champion III
Partner - Champion III

In your situation one solution can be:

AAA:

Load * resident myTable where Language = 'English';

store * from AAA into English.qvd;

Drop table AAA;

AAA:

Load * resident myTable where Language = 'French';

store * from AAA into French.qvd;

Drop table AAA;

and so on

Not applicable
Author

Hi Magen,

create a variable with a concatenated list of your possible languages and then use a for loop to cycle through each.

Set vAll_languages = 'French','English','Spanish';

For Each vlanguage in $(vAll_languages)

Table1:

Load xxxxx

From yyyy

Where Language = '$(vlanguage)'

Store Table1 Into $(vlanguage).qvd;

Drop Table1;

Next;

something along those lines, if you are doing specific code for each language though, you'd need to incorporate the adjusted code for each value in the variable.

Hope that helps

Joe

jagan
Luminary Alumni
Luminary Alumni

Hi,

If you have fixed number of languages then this is the best approach

Language1:

Load * ,

SomeCalculation

resident myTable where Language = 'Language1';

store * from Language1 into Language1.qvd;

Drop table Language1;

Language2:

Load * ,

SomeCalculation

resident myTable where Language = 'Language2';

store * from Language2 into Language2.qvd;

Drop table Language2;

'

'

'

'

Or you can use If() to find the language and calculate based on the language and generate a single qvd.

Hope this helps you.

Regards,

Jagan.