Link to home
Start Free TrialLog in
Avatar of Lulu0
Lulu0Flag for United States of America

asked on

Nested IF Statements

I'm unable to execute the query below. Is there a limit on nested IF's? I get the error "Expression is too complex".

iif(Delivery_Status = ' ' or Delivery_Status is null,'Missing Data'
      ,iif(Expected_Date < Ready_Date,'Bad Settings'
            ,iif(Create_Date > Order_Date,'Bad Entry'
                  ,iif((abs(actual_days - sys_days)>1)
                        ,iif(Loc <> Primary_Loc,'Bad Loc'
                              ,iif(used_type <> Primary_Type,'Bad Type'
                                    ,iif(hours>48,'Too long'
                                          ,iif(Actual_Pickup_Date <> Sched_Pickup_Date and Actual_Pickup_Date is not null and Sched_Pickup_Date is not null
                                                ,iif(Actual_Pickup_Date < Sched_Pickup_Date,'Early Pickup'
                                                      ,'Late Pickup'
                                                )
                                                ,iif((actual_days - sys_days)<-1, 'Fast Transit'
                                                      ,iif((actual_days - sys_days)>1,'Slow Transit','Unknown')
                                                )
                                          )
                                    )
                              )
                        )
                        ,iif(actual_days < sys_days,'Fast Transit'
                              ,iif(actual_days > sys_days, 'Slow Transit','Unknown')
                        )
                  )
            )
      )
);
ASKER CERTIFIED SOLUTION
Avatar of AielloJ
AielloJ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial