6 Replies Latest reply on Aug 10, 2017 6:21 PM by sunil.sachdeva

    SQL Help - IF within a CASE

    katie worthen

      Trying to calculate a different conditional color whether [Type] is either 'Long Cycle' or 'Short Cycle'.

       

      Getting this error on the string shown below, "Expected 'END' to match 'CASE' at character '0'.

      Where [Type] is a dimension and [PL Ratio] is a continuous calculation.

       

       

      CASE [Type]

      WHEN 'Long Cycle'

          THEN

          (IF [PL Ratio]<2 THEN 'RED'

          ELSEIF ([PL Ratio]>=2 AND [PL Ratio]<3) THEN 'YELLOW'

          ELSE 'GREEN'

          END)

          ELSEIF

          (IF [PL Ratio]<1 THEN 'RED'

          ELSEIF ([PL Ratio]>=1.25 AND [PL Ratio]<1) THEN 'YELLOW'

          ELSE 'GREEN'

          END)

      END