Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Not applicable

Error with multiple if statements

Hi ,

I am trying to enable if condition to create a calculated field called Results.DateShip.

However I get strange result for Results.DateShip = 570710725 and 570710731

if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='good',

  EO1.DateShip,

  Date(today(),'YYYYMMDD')),

if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='late',

  EO1.DateShip,

  Date(today()+1,'YYYYMMDD')),

if(Final.DateRequest>today(),

  EO1.DateShip,

  Date(Final.DateRequest,'YYYYMMDD')) as Results.DateShip

Can anyone suggest where I am going wrong ?

Thanks for any help.

Tags (1)
5 Replies
Not applicable

Re: Error with multiple if statements

you may try it like this date(today(),'YYYY/MM?DD')

Re: Error with multiple if statements

Hi,

Are you getting results without error? seems there is an error with nested if. can you post the sample?

May be try like this..

if(not (Final.DateRequest<=today() and ECL.CutoffTimeCheck='good'),

      Date(today(),'YYYYMMDD'),

  if(not (Final.DateRequest<=today() and ECL.CutoffTimeCheck='late'),

      Date(today()+1,'YYYYMMDD'),

  if(not (Final.DateRequest>today()),

      Date(Final.DateRequest,'YYYYMMDD'),

  if((Final.DateRequest<=today()and (ECL.CutoffTimeCheck='good' or ECL.CutoffTimeCheck='late')) or (Final.DateRequest>today()),

      EO1.DateShip)))) as Results.DateShip

thabang_petje
Contributor III

Re: Error with multiple if statements

Hi,

Please try:

if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='good', EO1.DateShip, Date(today(),'YYYYMMDD'),

      if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='late', EO1.DateShip, Date(today()+1,'YYYYMMDD'),

          if(Final.DateRequest>today(), EO1.DateShip, Date(Final.DateRequest,'YYYYMMDD')

          )

    )

) as Results.DateShip

It looks to me that the comma was not on the right place. Please try this.


balrajahlawat
Esteemed Contributor

Re: Error with multiple if statements

I think, comparing of Date at UI would not work with if condition...

Would suggest to do same at script something like this?

Comparing 2 date fields set analysis

QlikView Date fields

Also make sure format should be same while comparing like this?

Why don’t my dates work?

MVP
MVP

Re: Error with multiple if statements

Hi,

Nested If syntax is

=If(Conditon1, True Expression1,

     If(Condition2, True Expression2,

          If(Condition3, True Expression3, False Expression) AS DimName

So your expression should be

if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='good',

  EO1.DateShip,

if(Final.DateRequest<=today()and ECL.CutoffTimeCheck='late',

  EO1.DateShip,

  if(Final.DateRequest>today(),

  EO1.DateShip,

  Date(Final.DateRequest,'YYYYMMDD')) ))as Results.DateShip

Hope this helps you.

Regards,

jagan.

Community Browser