Home » Developer & Programmer » Reports & Discoverer » If Statement Defining current data to new name (Windows)
If Statement Defining current data to new name [message #559522] Tue, 03 July 2012 15:59 Go to next message
meghanpwong
Messages: 1
Registered: July 2012
Location: MINNESOTA
Junior Member
I would like to know if there is a way to define values in a field to a defined new data.

As an example:
If field A value is equals to May, then set field "Quarter" data value to "2nd Quarter".
If field A value is equals to January, then set field "Quarter" data value to 1st Quarter".

Is there a calculation that I can use?

Thanks in advance.
Re: If Statement Defining current data to new name [message #559542 is a reply to message #559522] Tue, 03 July 2012 22:13 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
There are a few options. The first one is achieved in the report's query itself. For example:
select field_A,
       case when field_A = 'January' then '1st Quarter'
            when field_A = 'May'     then '2nd Quarter'
            else                          'Unknown'
       end quarter,
       ...
from your_table
where ...


Another one uses the formula column (i.e. you don't SELECT "quarter" field in the query itself, but compose its value in the formula column). The principle is the same - create a formula column, make it return a character value (which is long enough to accept values you mean to return) and put the same CASE into the function body. Note use of the colon (:) sign in front of the "field_A". Report's query should still
select field_A from your_table
For example:
function f_get_quarter return varchar2 is
  retval varchar2(30);
begin
  retval := case when :field_A = 'January' then '1st Quarter'
                 when :field_A = 'May'     then '2nd Quarter'
                 else                           'Unknown'
            end;
  return (retval);
end;
Re: If Statement Defining current data to new name [message #562732 is a reply to message #559522] Sat, 04 August 2012 00:06 Go to previous message
dude4084
Messages: 222
Registered: March 2005
Location: Mux
Senior Member
Just to give more idea, you may use trunc function with 'Q' format and use it according to your need
Previous Topic: Matrix Graph Report
Next Topic: batch compilation of rdf reports in linux without opening rwbuilder
Goto Forum:
  


Current Time: Thu Mar 28 07:31:02 CDT 2024