1 Reply Latest reply on Apr 12, 2017 4:03 AM by Sonali chavan

    Case Statemnt with ranges

    Rajashmita Kar

      How to write this below if statement in CASE?

       

       

      IF [Year]=2010 THEN sum(Sales)

      ELSEIF [Year]>2010 and [YEAR]<=2014 THEN sum(Sales)+1

      ELSEIF [Year]>2014 and [YEAR]<=2017 THEN sum(Sales)+2

      ELSEIF [Year] = NULL THEN NULL

      ELSE "na"

      END

        • 1. Re: Case Statemnt with ranges
          Sonali chavan

          Hi Rajashmita,

           

          Writing same statement is case in somewhat impossible .

           

          how about, if we rewrite above if statement as follows:

           

          IF MAX([Year])=2010 THEN sum([Sale])

          ELSEIF ( MAX([Year])=2011 or MAX([Year])=2012 or MAX([Year])=2013) then sum([Sale])+1

          ELSEIF (MAX([Year])=2014 or MAX([Year])=2015) THEN sum([Sale])+2

          ELSEIF ISNULL(MAX([Year])) then null

          ELSE 0

           

          END

           

           

          -Sonali