Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
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
Author

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

settu_periasamy
Master III
Master III

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

Anonymous
Not applicable
Author

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.


Anonymous
Not applicable
Author

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?

jagan
Luminary Alumni
Luminary Alumni

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.