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

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Use an IF statment store in table on script

Hello,

I want to use an if statment  store in a table in a load script.

Example :

My Table Source

ID    |   IFSTATMENT

1         IF(CODE=C2,'A','B')

2         IF(CODE=C1,'C','D')

Target TABLE

CODE | ID  | VALEUR

   C2      1      A

   C2      2      D

How generate the target table ?

I have tryed with an Lookup function but the result is

CODE | ID  | VALEUR

   C2      1      IF(CODE=C2,'A','B')

   C2      2      IF(CODE=C1,'C','D')

What is the syntax for QLIKVIEW interpreter the if statment ?

Thanks !

Labels (1)
1 Solution

Accepted Solutions
Not applicable
Author

try this:

iftbl:

Mapping LOAD * INLINE [

    ID,F1

    1,"IF(CODE=C2,'A','B')"

    2,"IF(CODE=C1,'C','D')"

];

LOAD *, Evaluate( ApplyMap('iftbl',ID)) as ifexpr;

load * INLINE [

CODE, ID

C2,1

C2,2

];

View solution in original post

8 Replies
marcus_sommer
MVP
MVP

What is the aim for the target-table? What do you want to do?

- Marcus

Not applicable
Author

In fact, I recovers the rules of calculation of indicators from a configuration file because the rules change regularly.

ex : Monday : If(Code='A',1,0)

      Thursday If(Code='A',5,0)

And i want to generate automatically  the rules in my Load Script

MayilVahanan
MVP
MVP

HI

Try with Mapping and ApplyMap concept for solve your requirement

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
marcus_sommer
MVP
MVP

But you have already this if you loaded your "My Table Source".

Not applicable
Author

try this:

iftbl:

Mapping LOAD * INLINE [

    ID,F1

    1,"IF(CODE=C2,'A','B')"

    2,"IF(CODE=C1,'C','D')"

];

LOAD *, Evaluate( ApplyMap('iftbl',ID)) as ifexpr;

load * INLINE [

CODE, ID

C2,1

C2,2

];

Not applicable
Author

"My Source Table" is loaded with values of config file !

I want execute the IF statement on the load of my Target table!

Not applicable
Author

Thanks Dariusz it works !!!

Not applicable
Author