Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
sgg_gaikwad
Partner - Contributor II
Partner - Contributor II

Inculde function with If statement is it Possible ...?

This script is not working......

Config:

LOAD

ScriptConfig

FROM Configurations.xls

(biff, embedded labels, table is ObjectConfig$);

let VRow = NoOfRows('Config');

let VInclude = FieldValue('ScriptConfig',$(VRow));

if $(VInclude) then

$(Include= File1.qvs)

ELSE

$(Include= File2.qvs)

EXIT Script;

end if

12 Replies
swuehl
MVP
MVP

Could you post a sample Configuration.xls?

danieloberbilli
Specialist II
Specialist II

did you try to run it with the 'exit script;' at the very end (so after 'end if')?

sgg_gaikwad
Partner - Contributor II
Partner - Contributor II
Author

that file is having YES  value..

Means if I pass Yes value in the ScriptConfig Column then first Qvs should work other wise Else part should execute.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Think about it: a table may contain 1000s of identical rows, but a field from that table will contain only one value: the one  distinct value that appears in every row...

Your index of the last row is probably out of bounds by a large margin for field ScriptConfig. Does the Configurations.xls file contain empty values in column ScriptConfig?

Best,

Peter

sgg_gaikwad
Partner - Contributor II
Partner - Contributor II
Author

Hey Daniel Yes i have tried in that way Still not working ....?

sgg_gaikwad
Partner - Contributor II
Partner - Contributor II
Author

Hey Peter That Excel file is having One Column and One Row....

maxgro
MVP
MVP

I tried this and it works (all files inthe same dir)


DIRECTORY;

Config:

LOAD ScriptConfig

FROM

Configurations.xls

(biff, embedded labels, table is ObjectConfig$);

let VRow = NoOfRows('Config');

let VInclude = FieldValue('ScriptConfig',$(VRow));

trace  $(VInclude);

if len(trim('$(VInclude)'))>0 then

  trace include file1;

  $(Include=File1.qvs);

ELSE

  trace include file2;

  $(Include=File2.qvs);

  EXIT Script;

end if;

Peter_Cammaert
Partner - Champion III
Partner - Champion III

So you will encounter this problem as soon as you have two rows with a YES-value.

BTW the code in the middle:

if $(VInclude) then

:

with your data translates into

if YES then

:


which doesn't do much (except if you store -1 in variable YES), or into


if then

:


which is an illegal statement.


I think Massimo's IF statement will work more reliably.


Peter

sgg_gaikwad
Partner - Contributor II
Partner - Contributor II
Author

Hey hi Massimo,

         The above script is worked for my First If statement but ELSE part is not working in the situation.

and one more question are you passing Text value in that column or Numeric one..?