Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Not applicable

Question on Scripting

 

  What could be the problem with this script ?

=if(if(Style='TVB' and if(DISPLAY_YEAR='2007',0,(If(DISPLAY_YEAR='2008',1,If(DISPLAY_YEAR='2009',2,If(DISPLAY_YEAR='2010',2,If(DISPLAY_YEAR='2011',3,4)))))),

if(if(Style='RY903C' and (If(DISPLAY_YEAR='2008',0,If(DISPLAY_YEAR='2009',1,If(DISPLAY_YEAR='2010',3,If(DISPLAY_YEAR='2011',4))))),

if(Style='RUSSA1' and If(DISPLAY_YEAR='2010',0,If(DISPLAY_YEAR='2011',1,If(DISPLAY_YEAR='2012',2)))

Regards

Mhatim

1 Solution

Accepted Solutions
MVP
MVP

Re: Question on Scripting

Hope I got correctly what you are trying to achieve:

=if(Style='TVB',if(DISPLAY_YEAR='2007',0, If(DISPLAY_YEAR='2008',1,If(DISPLAY_YEAR='2009',2,If(DISPLAY_YEAR='2010',2,If(DISPLAY_YEAR='2011',3,4))))),

if(Style='RY903C',If(DISPLAY_YEAR='2008',0,If(DISPLAY_YEAR='2009',1,If(DISPLAY_YEAR='2010',3,If(DISPLAY_YEAR='2011',4)))),

if(Style='RUSSA1',If(DISPLAY_YEAR='2010',0,If(DISPLAY_YEAR='2011',1,If(DISPLAY_YEAR='2012',2))))))

6 Replies
MVP
MVP

Re: Question on Scripting

At first glance, some missing brackets (about 4-5 closing)? Then, some of your conditionals are missing a then branch, wich is mandatory.

Not applicable

Re: Question on Scripting

Thanks for your response

I have changed the If statement to take care of all the conditionals however

When I complete the brackets this what I get

                                                                                                                                                                           Red underline comes before the third bracket at the end.

Please advise.

=if(if(Style='TVB' and if(DISPLAY_YEAR='2007',0,(If(DISPLAY_YEAR='2008',1,If(DISPLAY_YEAR='2009',2,If(DISPLAY_YEAR='2010',2,If(DISPLAY_YEAR='2011',3,4)))))),

if(Style='RY903C' and (If(DISPLAY_YEAR='2008',0,If(DISPLAY_YEAR='2009',1,If(DISPLAY_YEAR='2010',3,If(DISPLAY_YEAR='2011',4))))),

if (Style='RUSSA1' and If (DISPLAY_YEAR='2010',0,If(DISPLAY_YEAR='2011',1,If(DISPLAY_YEAR='2012',2)))))))

Re: Question on Scripting

HI

Try this,

=if(if(Style='TVB' and if(DISPLAY_YEAR='2007',0,(If(DISPLAY_YEAR='2008',1,If(DISPLAY_YEAR='2009',2,If(DISPLAY_YEAR='2010',2,If(DISPLAY_YEAR='2011',3,4))))),

if(Style='RY903C' and (If(DISPLAY_YEAR='2008',0,If(DISPLAY_YEAR='2009',1,If(DISPLAY_YEAR='2010',3,If(DISPLAY_YEAR='2011',4))))),

if (Style='RUSSA1' and If (DISPLAY_YEAR='2010',0,If(DISPLAY_YEAR='2011',1,If(DISPLAY_YEAR='2012',2))))))))

But some condition is missing in some if statement..Please fill it

MVP
MVP

Re: Question on Scripting

Hope I got correctly what you are trying to achieve:

=if(Style='TVB',if(DISPLAY_YEAR='2007',0, If(DISPLAY_YEAR='2008',1,If(DISPLAY_YEAR='2009',2,If(DISPLAY_YEAR='2010',2,If(DISPLAY_YEAR='2011',3,4))))),

if(Style='RY903C',If(DISPLAY_YEAR='2008',0,If(DISPLAY_YEAR='2009',1,If(DISPLAY_YEAR='2010',3,If(DISPLAY_YEAR='2011',4)))),

if(Style='RUSSA1',If(DISPLAY_YEAR='2010',0,If(DISPLAY_YEAR='2011',1,If(DISPLAY_YEAR='2012',2))))))

Not applicable

Re: Question on Scripting

Thanks Ramasamy,

Not able to figure out the missing ones.

Can you please help me with it.

Regards.

Mhatim

robert99
Valued Contributor II

Re: Question on Scripting

Should you start with two if's (i never do)

=if(Style='TVB' and DISPLAY_YEAR='2007',0,

etc

its

if(a=b and / or c=b etc,then (may include an if), else (may include an if)

if you have more than one if statement the brackets are all maybe closed at the end not part way through

not

If(DISPLAY_YEAR='2011',3,4)))))),

try dropping all if if statement

I don't think this will work at any point in the formula


if(if(Style='RY903C' and

its always if,then,else not if(if

I believe

Community Browser