3 Replies Latest reply on Jun 25, 2013 4:46 PM by bha.jand

    Help with If Statement

    Elizabeth Coleman


      I need help in writing this If Statement:

       

      If([ invoice date]) = "" and(Str([Moved to week])) = "200101" then 'Unscheduled'

      elseif ([ Moved to Week]) > ([Slotted Week]) then 'Moved Out'

      elseif ([invoice date]) then 'Invoiced'

      end

       

      I'm getting an error: Expected type Boolean, found datetime.  Comparison in 'If' expression must be boolean type.

        • 1. Re: Help with If Statement
          Tracy Rodgers

          Hi Elizabeth,

           

          Try something like the following:

           

          If isnull([ invoice date]) and(Str([Moved to week])) = "200101" then 'Unscheduled'

           

          elseif ([Moved to week]) > ([Slotted Week]) then 'Moved Out'

           

          elseif ([ invoice date])=[ invoice date] then 'Invoiced'

           

          end

           

          Hope this helps!

           

          -Tracy

          1 of 1 people found this helpful
          • 2. Re: Help with If Statement
            Elizabeth Coleman

            Tracy,

            thanks for your help but I missed something in the formula causing  null values.  I changed the formula to the following thinking it will correct the null values but it didn't.

             

            If (Str([ Moved to Week]) = "200101" and isnull([  Inv dt])) then 'Unscheduled'

             

            elseif ([ Moved to Week]) > ([Slotted Week]) then 'Moved Out'

             

            elseif ([  Inv dt])=[  Inv dt] then 'Invoiced'

             

            end

             

            I think it's something in the first part of the formula that is causing the null value.

            • 3. Re: Help with If Statement
              bha.jand

              Hi Elizabeth,

               

              Please try the following:

               

              If (Str([ Moved to Week]) = "200101" then (if isnull([  Inv dt])) then 'Unscheduled' ) end

               

              elseif ([ Moved to Week]) > ([Slotted Week]) then 'Moved Out'

               

              else 'Invoiced'

               

              end

               

              Hope this helps.