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

Set analysys or if/else?

Hello guys, i don´t know what to use . i have to use  the code that is showed here in all accounts (i have a lot of accounts) and in 5 accounts i have to use another code.

(FOR ALL ACCOUNTS)

FOR i = 1 TO $(vTotal)

load

  COLUMN1

(AÑOMESCONTINUO + $(i)) as AÑOMESCONTINUO

RESIDENT TMP2;

NEXT i;

DROP TABLE TMP2; 

(FOR 5 ACOUNTS)

i dont know but it´s not important .

I thought about an If/ else like this

If ((Match(ACCOUNT, '1', '2', '3', '4', '5') , missing code  , the code i´ve put)

But it´s not working, maybe because im doing the syntax in a incorrect form.

Should i use set analysis ?

Thank you all

Cheers

4 Replies
Anonymous
Not applicable
Author

Hi,

I guess the variable i represents your accounts? If so you can use:

FOR i = 1 TO $(vTotal)


if match( $(i), 1,2,3,4,5)  then


     'DIFFERENT CODE'


ELSE


load

  COLUMN1

(AÑOMESCONTINUO + $(i)) as AÑOMESCONTINUO

RESIDENT TMP2;


end if


NEXT i;

DROP TABLE TMP2; 


In script you cannot use set analysis syntax. Depending on what you want to do with account 1 to 5 you could also use if in your load statement instead of control statement outside, but for this you need to explain your requirement.


Hope this helps.


Best regards

Stefan



Not applicable
Author

Hello. Thank you for the answer, but no, the variable is the number of months

Anonymous
Not applicable
Author

Hi,

I can't see ACCOUNT as Field or anywhere else in your script. could you please provide a sample app and explain your requirement?

Best regards

Stefan

Not applicable
Author

One option might to be to load your accounts and use them in an outer loop. The inner loop will execute the code for each account.


For example:

// Load accounts:

Accounts_Table:

LOAD * Inline

[

  1001,

  1002,

  1003,

];

// Loop through each account and execute account-specific code:

FOR i = 1 to NoOfRows('Accounts_Table')

// You can get individual account value using $(i)

NEXT