Qlik Community

Ask a Question

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Talk to Experts Tuesday, January 26th at 10AM EST: Qlik Sense. REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
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.

5 Replies
Not applicable

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

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

Partner
Partner

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.


Champion
Champion

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 & Luminary
MVP & Luminary

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.