Search code examples
sqloracle10gcognos-10

Should I use DECODE or CASE in Cognos 10 Report Studio Expressions?


I'd like to take a date stored as something like 201609 and display something like Fall 2016 as an Expression in Cognos Report Studio (Cognos 10).

I really only need to check the months 01, 05, and 09 for Winter, Spring, and Fall.

I've checked this question about case and decode and I'm converting old Cognos7 reports to Cognos 10 Report Studio. I've also read the documentation for the case statement for being used inside a Select clause but I don't see any examples of how to write it as an expression in a calculated column or even as a Singleton (most likely use for what I'm looking for).

The way I've converted the old technique from Cognos7 to Cognos 10 Report studio is something like:

 CONCAT(CONCAT(DECODE(SUBSTR([TermDate],5 ,2),'09','Fall' ,'01','Winter','Spring')
 , ' ') , SUBSTR([TermDate],1 ,4))

I'd be very interested in how to do this in a more efficient, up-to-date method in Cognos 10 Report Studio and whether CASE is what I need to use in Expression fields.


Solution

  • After a few more minutes, I realized I was on the right track. Here is an approximate solution.

    The following expression can be entered into an Expression field in Cognos 10 Report Studio either as a calculated column or as a Singleton.

    CASE SUBSTR([TermDate],5 ,2) WHEN '09' THEN 'Fall'
    WHEN '01' THEN 'Winter'
    WHEN '05' THEN 'Spring'
    END || ' ' || SUBSTR([TermDate], 1, 4)