Sorting the column of VARCHAR in report

Hi,
I want to sort the column in report with the following scenario,
I have a column name with PERIOD as VarChar with values APR-11,FEB-11,JAN-11,JUN-11,MAR-11,MAY-11 in a report
As you can see, It is sorting in Alphabetic order but I need to arrange in JAN-11,FEB-11,MAR-11,APR-11,MAY-11,JUN-11
So can anyone has a good work around solution?
regards
Vj

Here is your challenge. How do you get Jan-12 to come after Dec-11? Adil's solution is partial. It works only for the current year. Once you cross over to the next year, it stops working because you are only sorting the month. You must include the year to make the solution complete. So here is a solution that always works. It involves some math so I'll explain the math first.
Let's look at your values:
Jan-11
Feb-11
Dec-11
Jan-12
If you convert each month to a number (i.e., Jan = 1, Feb =2... etc.) and then multiply the year by 1000 and finally add them together, we get this:
Jan-11 1 --> 11001
Feb-11 2 --> 11002
Dec-11 12 --> 11012
Jan-12 1 --> 12001
You get the picture. The last column will be in the order you seek because the integer will always be greater than the previous month-year even at the transition from December to January. BTW, I multiplied the two digit year by 1000 to ensure that there would be no overlap.
Now you can sort by this third column. Here is the code that does this:
CAST(CASE WHEN LEFT(Table.PERIOD, 3) = 'Jan' THEN '1' WHEN LEFT(Table.PERIOD, 3) = 'Feb' THEN '2' WHEN LEFT(Table.PERIOD, 3) = 'Mar' THEN '3' WHEN LEFT(Table.PERIOD, 3) = 'Apr' THEN '4' WHEN LEFT(Table.PERIOD, 3) = 'May' THEN '5' WHEN LEFT(Table.PERIOD, 3) = 'Jun' THEN '6' WHEN LEFT(Table.PERIOD, 3) = 'Jul' THEN '7' WHEN LEFT(Table.PERIOD, 3) = 'Aug' THEN '8' WHEN LEFT(Table.PERIOD, 3) = 'Sep' THEN '9' WHEN LEFT(Table.PERIOD, 3) = 'Oct' THEN '10' WHEN LEFT(Table.PERIOD, 3) = 'Nov' THEN '11' WHEN LEFT(Table.PERIOD, 3) = 'Dec' THEN '12' END AS INTEGER)+CAST(RIGHT(Table.PERIOD, 2) AS INTEGER)*1000
This solves your problem now even when the month-year crosses to the next year. There you go!

Similar Messages

  • Re : Issue with the column display in Bex reports

    Hello Gurus,
    I have an issue with the reports in Bex, this is a bit confusing scenario I would try to explain in more details. A query was already built for monthly Report in Sales and Billing for which the variable were  Calender month/year range 1 (mandatory), range 2 range 3 range 4. These 4 variable were created and moved to column rows in query.
    Later the user wanted the copy of same report but he wanted the variables to be Calender date range 1 (mandatory), range 2, range 3 , range 4. I have created them with 0calenderday as reference and moved to the columns.
    for the monthly report text variables were already existing for the Calender month/ year, but for the daily report text variable were not existing for Dates. I have created a text variable for the date in the following way processing by
    " replacement path" and reference characteristic as 0calday and in the replacement path tab.. in replace variable the selection is info object, the next option Replace with " External charactersitic value key " .
    By creating this text variable the dates were being displayed in the colum header like 11/01/2013 - 11/30/2013 which satisfies the requirement.
    But the user wanted to see the report same like monthly report when the mandatory variable Calender year/ month is selected, the rest of the columns range 2, range 3, range 4 are displayed as unassigned in the report. but coming back to the daily report when the user is giving the Calender date rage 1, he is finding that Calender date range 2, range 3, range 4  are also being displayed with values. He want to see the Calender date range 2,3,4 as unassigned in the report just like monthly. Please find the images attached.
    As Calender month/ year is predefined, if the calender range values are not given it would show up as not assigned default. I have created a separate text variable for Calender day, I believe that could be the reason rest of the columns are not showing up as unassigned. The user want to see them as unassigned like monthly report columns.
    I tried different ways changing the text variables but I could not change the display of the columns in Calender date report by the option - replace with ----> External characteristic value key, key, label. when I chose the option external characteristic value then the date was showing up in the text of the column when report is run ( Please find the image for the reference in the attachment ). . I request you to help me out in this. Please find the images of the variables and output below.

    Anshu,
    Thank you very much for above code I  made minor changes to the code that finally worked. I created 4 different text variables needed for Calender date range 1, 2 ,3 ,4. Please find the code below for the text variable that worked in the system
    WHEN 'ZTEXT_CAL1'.
       READ TABLE I_T_VAR_RANGE INTO loc_var_range
       WITH KEY VNAM = 'ZCALDATE1'.
        IF loc_var_range-LOW = '#'.
          dt_low = 'Not Assigned'.
          dt_high = 'Not Assigned'.
          CONCATENATE dt_low '-' dt_high INTO l_s_range-low.
        ELSE.
          CONCATENATE loc_var_range-low+4(2) '/' loc_var_range-low+6(2) '/' loc_var_range-low+0(4) into dt_low.
          CONCATENATE loc_var_range-high+4(2) '/' loc_var_range-high+6(2) '/' loc_var_range-high+0(4) into dt_high.
          CONCATENATE dt_low '-' dt_high INTO l_s_range-low.
        ENDIF.
            L_S_RANGE-SIGN = 'I'.
            L_S_RANGE-OPT = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.

  • How to increase the column size of interactive report

    Hi , I am using apex 4.2 and theme 25 ..
    i did not find any option to increase the column size of interactive report. where as in classic report i can do so ,,
    Please guide me to achieve that.
    Thank You,
    Nihar Narla

    Nihar Narla wrote:
    Hi , I am using apex 4.2 and theme 25 ..
    i did not find any option to increase the column size of interactive report. where as in classic report i can do soThis can be done using CSS. Create a rule like this in the page Inline CSS property:
    .apexir_WORKSHEET_DATA td[headers="COLUMN_ALIAS"] {
      width: 10em;
    }where COLUMN_ALIAS is the alias of the column in the report query and the width measure is whatever you require.

  • How do I sort songs in the iTunes store?  You used to be able to click on the column header to sort the column (ie Popularity)?

    How do I sort songs in the iTunes store?  You used to be able to click on the column header to sort the column (ie Popularity)?

    It seems this is a "backwards" upgrade from Apple in their iTunes 11 release....like you, I used to use that function in the iTunes store to sort through and decide which song version to purchase.   (For a large returned list of songs...see all...then sort by any of the headers, including Popularity...this functionality is now gone.)  
    The iPad always suffered from this...was never able to sort on those same column headers with an iPad.   It seems, this new iTunes release killed that functionality on the Mac as well.
    Just one of the few things that went wrong with number 11!
    Better luck next time,

  • How to extract the column width in ALv report if its executed in background

    I am executing an ALV report in background , in front end i am getting data properly, in back end for some columns some of the digits are missing.For example if PO no is of 10 digits it will display only 8 becos column size is like that , how to extract coulmns in back ground.
    I have executed in background and checked the spool and  for some of the columns width is not sufficient to display comeplete data so please suggest how to extract the columns sizes if executed inj background for an ALV

    Hi Deepthi,
    you can try with the above mentioned suggestions ,if its worked its fine ,
    If not use Docking container instead of custom container, For ALV in back ground jobs, its suggest to use docking container instead of custom container , below you can find the declaration for docking container and code to use docking and custom container in your program for fore and back ground.
    or you can use docking container alone for both operations.
    Data : G_DOCK1 TYPE REF TO CL_GUI_DOCKING_CONTAINER,
    IF CCON IS INITIAL. (ccon is container name )
    *Check whether the program is run in batch or foreground
        IF CL_GUI_ALV_GRID=>OFFLINE( ) IS INITIAL.
    *Run in foreground
          CREATE OBJECT CCON
            EXPORTING
              CONTAINER_NAME = 'CON1'.
        CREATE OBJECT GRID1
            EXPORTING
              I_PARENT = parent_1.
    ELSE.
    *Run in background
          CREATE OBJECT GRID1
            EXPORTING
              I_PARENT = G_DOCK1.
        ENDIF.
      ENDIF.
    B&R,
    Saravana.S

  • How to set up a column link to the column attribute in a report

    Hi All
    I have 6 column in a sql report in a page, column names are (Devicename devicerole,from etc).
    Now i need to set a link to this column and this need to link to the another page
    Thanks & Regards
    Srikkanth.M
    Edited by: Srikkanth.M on Apr 6, 2011 6:17 PM

    Hi
    Read this and follow it...
    >
    Go to the report attributes, then click on the edit link button by the side of the column you want to be a link to get to the column attributes.
    >
    So...
    1. Go to edit the page that contains your report.
    2. Click on the report region as if you were going to edit the report query.
    3. Click the Report Attributes tab.
    4. Click the button at the side of the column in question.
    5. Scroll down to the Column Link section and fill in the details.
    I really can't put it much more simply than that...
    Cheers
    Ben

  • How to show the columns dynamically in OBIEE report based on the selection?

    Hi,
    I have a requirement where the columns should be dynamically shown in report based on what we select in propmt page.
    I'm creating a report in OBIEE where i want to give an option to the end user to select the columns whichever he wants to see in the report.
    For example I have the following columns in the report already:
    Customer Name,
    Customer Number,
    Bank Account,
    Address
    I want to give an option to the user to select 'Customer Mail ID' dynamically and see the column to be displyed in the report along with the existing columns.
    Through 'Column Selector' user can select a single column at a time, but if he want to select more than one column, how can we do this ?
    Please help me out in resolving this issue.
    Thanks,
    Chaithanya.

    Hi Chaithanya,
    there's not a straight solution for this. You can create different analysis containing different number of columns and then directing the user to this analysis using Action Links or you can also use View Selector to switch from one view (analysis) to the other. But it's not going to be very flexible nor dynamic.
    J.

  • How can i Auto Size the Column width in RDLC Report

    Hi Friend's,
    I have created Windows application with RDLC Report. I am binding(Generating) dynamic columns and data's in RDLC Report Using Matrix control, I need to make Auto size of Column width for each Column in
    Matrix of RDLC report. So Can any one suggest me to make the Auto Size of Column Width in RDLC.
    Thanks in Advance,
    Mohan G

    Hi Mohan,
    In Reporting Services, the column width/height is hard-coded, hence, we cannot set the column width/height dynamically or based on an expression. So is the report size.
    In addition, since it is a RDLC report, we need a ReportViewer control to display this report within a custom application. If you need to change the size of the whole report, we can set the AsyncRendering property of the ReportViewer control to false, and
    set the SizeToReportContent property to true.
    Regards,
    Mike Yin
    TechNet Community Support

  • Adding the columns dynamically in crystal report

    Hi,
      I am developing a application using asp.net and crystal report. In a report the column is created dynamically( ie, the report gets input from a sp which returns N no. of columns). Since i dont know the column name and no. of columns at design time i am not able to create the report. If any of you have any idea on adding the columns dynamically please send me the code or the link.
    Thanks
    Sankar

    Hello Sankar,
    please see CS code for VS 2005 below to add a database field to a report using inproc RAS.
    This sampels retrieves the table column name from the database and adds it to the report.
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.ReportAppServer.Controllers;
    using CrystalDecisions.ReportAppServer.ClientDoc;
    using CrystalDecisions.ReportAppServer.DataDefModel;
    namespace CS_Add_Field_inproc
        public partial class Form1 : Form
            // CR Declarations
            ReportDocument boReportDocument;
            ISCDReportClientDocument boReportClientDocument;
            CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection;
            CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject boFieldObject;
            public Form1()
                InitializeComponent();
                //Create a new ReportDocument
                boReportDocument = new ReportDocument();
                // load the RPT file
                boReportDocument.Load("..
    AddField.rpt");
                //Access the ReportClientDocument in the ReportDocument (EROM bridge)
                boReportClientDocument = boReportDocument.ReportClientDocument;
                //Get the first section in the details section
                   boSection = boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];
                   //Create the field object that we will add to the report and set all of its properties
                   boFieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();
                //Set which field to use for the data to be displayed
                   boFieldObject.DataSourceName = "{Customer.City}";
                   boFieldObject.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
                   boFieldObject.Left = 4 * 1440; //1440 twips per inch
                   boFieldObject.Width = 3 * 1440;
                   boFieldObject.FontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
                   boFieldObject.FontColor.Font.Name = "Arial";
                   boFieldObject.FontColor.Font.Size = 10;
                   boFieldObject.Format.HorizontalAlignment = CrystalDecisions.ReportAppServer.ReportDefModel.CrAlignmentEnum.crAlignmentLeft;
                   //Add the object to the report
                   boReportClientDocument.ReportDefController.ReportObjectController.Add(boFieldObject, boSection, -1);
                // show in reportviewer
                crystalReportViewer1.ReportSource = boReportDocument;
            private void button1_Click(object sender, EventArgs e)
                //Get the first section in the details section
                boSection = boReportClientDocument.ReportDefController.ReportDefinition.DetailArea.Sections[0];
                //Create the field object that we will add to the report and set all of its properties
                boFieldObject = new CrystalDecisions.ReportAppServer.ReportDefModel.FieldObject();
                //Set which field to use for the data to be displayed
                boFieldObject.DataSourceName = "{Customer.City}";
                boFieldObject.FieldValueType = CrystalDecisions.ReportAppServer.DataDefModel.CrFieldValueTypeEnum.crFieldValueTypeStringField;
                boFieldObject.Left = 4 * 1440; //1440 twips per inch
                boFieldObject.Width = 3 * 1440;
                boFieldObject.FontColor = new CrystalDecisions.ReportAppServer.ReportDefModel.FontColor();
                boFieldObject.FontColor.Font.Name = "Arial";
                boFieldObject.FontColor.Font.Size = 10;
                boFieldObject.Format.HorizontalAlignment = CrystalDecisions.ReportAppServer.ReportDefModel.CrAlignmentEnum.crAlignmentLeft;
                //Add the object to the report
                boReportClientDocument.ReportDefController.ReportObjectController.Add(boFieldObject, boSection, -1);
                // show in reportviewer
                crystalReportViewer1.ReportSource = boReportDocument;

  • Want to sort the columns while using GROUP BY ROLLUP.

    Want to order the below query using by "News' column in descending order and "Email address" column in Ascending order.
    Note: Sorting should not bring Total value to top. It is happening now.
    {code}
    SELECT decode(grouping(NVL(Client, 'NA')),1, 'Totals', NVL(Client, 'NA')) "Email (Login ID)",
    Location "Location",
    SUM(News) "News",
    SUM(Website) "Website",
    FROM VW_FX_USERDATA
    GROUP BY ROLLUP (((NVL(Client, 'NA')),Location,1, 'Totals', NVL(Client, 'NA')))
    {code}
    PLease let me know if you need any details.
    Edited by: Nagaraja Akkivalli on Sep 23, 2011 4:04 PM

    Thanks hm,
    Let me explain bit clearly.
    Say I am getting resultset as below.When I am executing above mentioned query.
    Client*        Location    News      Website       Total
    ABC        YD           9     0           4
    BCD        HB           12     7           13
    CDE        SI            1     18           3
    JNM        BI          25     0           4
    ZZZ        TI          0     221           77
    XYZ        TT          0     1           1
    Totals                      47     247           435I want it to as below. Here records are sorted in the descending order of the News Count and then Client*
    Client*        Location    News      Website       Total
    JNM        BI          25     0           4
    BCD        HB           12     7           13
    ABC        YD           9     0           4
    CDE        SI            1     18           3
    XYZ        TT          0     1           1
    ZZZ        TI          0     221           77
    Totals                      47     247           435If I order the column by News in the descending order, it is taking Totals value to the top. (Since I am using GROUP BY ROLLUP).
    Note: Sorting should not be applied to Totals.
    Hope this is clear to you. Let me know if you need any details.
    Thanks and Regards
    Nagaraja Akkivalli.

  • Can clicking on column heading sort the column contents instead of drill in

    I have a pivot table with data that the client doesn't want to drill into. Instead, they want to be able to click the column heading and have the pivot table re-sort the data in the table based on the data in that column. Is that possible, or are clickable column headings only used for drilling in OBIEE? Thanks.

    Madan -
    That seems like a feature that should be added to the Pivot Table view if they are going to have it in the Table View. Still, thanks for pointing out the "Enable column sorting in Dashboards" check box in the Table view. I'll see if I can either get this data into the Table view, or at least let the client know the limitations of OBIEE.
    Thanks again.
    Daniel

  • Sort the columns of a table

    Hi,
    There is a table with lot of data. I want to change the order in which the columns are displayed when the table is queries. Is there any way or i just have to drop the table and recreate again.
    Have a nice day.
    Thank you
    PK

    Hi,
    Like user637951 said, you only need to change the order in your query. Example:
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> desc employees;
    Name           Type         Nullable Default Comments                                                                                                                                                                                 
    EMPLOYEE_ID    NUMBER(6)                     Primary key of employees table.                                                                                                                                                          
    FIRST_NAME     VARCHAR2(20) Y                First name of the employee. A not null column.                                                                                                                                           
    LAST_NAME      VARCHAR2(25)                  Last name of the employee. A not null column.                                                                                                                                            
    EMAIL          VARCHAR2(25)                  Email id of the employee                                                                                                                                                                 
    PHONE_NUMBER   VARCHAR2(20) Y                Phone number of the employee; includes country code and area code                                                                                                                        
    HIRE_DATE      DATE                          Date when the employee started on this job. A not null column.                                                                                                                           
    JOB_ID         VARCHAR2(10)                  Current job of the employee; foreign key to job_id column of the
    jobs table. A not null column.                                                                                         
    SALARY         NUMBER(8,2)  Y                Monthly salary of the employee. Must be greater
    than zero (enforced by constraint emp_salary_min)                                                                                       
    COMMISSION_PCT NUMBER(2,2)  Y                Commission percentage of the employee; Only employees in sales
    department elgible for commission percentage                                                                             
    MANAGER_ID     NUMBER(6)    Y                Manager id of the employee; has same domain as manager_id in
    departments table. Foreign key to employee_id column of employees table.
    (useful for reflexive joins and CONNECT BY query)
    DEPARTMENT_ID  NUMBER(4)    Y                Department id where employee works; foreign key to department_id
    column of the departments table                                                                                        
    SQL> select e.employee_id, e.first_name, e.last_name from employees e where e.employee_id = 100;
    EMPLOYEE_ID FIRST_NAME           LAST_NAME
            100 Steven               King
    SQL> select e.first_name, e.last_name, e.employee_id from employees e where e.employee_id = 100;
    FIRST_NAME           LAST_NAME                 EMPLOYEE_ID
    Steven               King                              100
    SQL> Regards,

  • Problem in sorting the column

    Hi everybody,
    I observed that in OBIEE, if there are 2 strings which are comination of small & capital letters say "ATer", "Ago" then if i give order by as asending on these columns the second string is taking 2 nd place eventhough the 2nd letter of 2nd string is smallaer then the 2nd letter of 1st string. I think here capitals are having high priority then the small letters. Then if i want to make it as non-case sensitive then how can i customize the properties..? and where it is available...?
    Can anybody explain...?
    Thanks & Regards
    G. Kishore

    for this one instance - create another column as lower(column) and sort on it.

  • Why doesn't the bookmarks library have the ability to sort the columns by "folder" (The subdirectory folder they are stored within)? Would Firefox please add?

    Basically inside the bookmarks library, when searching for a particular bookmark, there is no way to display which folder that bookmark is saved to.
    It has been very frustrating to not be able to do this because I'm a guy that has probably 2000+ bookmarks for reference and if I want to be able to move the bookmarks or confirm they are in the folder I wish, I would like a way to be able to search for them and have it not just show their location as a web address but ALSO as where they are saved. Perhaps name that new column "Folder" like Microsoft does in windows when you display a folder in the "Detail" view you know?
    Thanks!

    *Show parent folder - https://addons.mozilla.org/en-US/firefox/addon/show-parent-folder/
    *Go to parent folder - https://addons.mozilla.org/en-US/firefox/addon/go-parent-folder/

  • Sort order column in a report

    hi all,
    I've seen in a dashboard (OBIEE 10.1.3) on linux os that is possible to sort the columns of the measures in a table (an arrow appears next to the name of the column), but I haven't noticed in the settings how get this result.
    is a feature of linux or you can apply this in windows? if so, how?
    thank you for the reply

    you have to enable the sorting for table view in Answers report. refer below article.
    http://gerardnico.com/wiki/dat/obiee/dashboard_column_sorting
    - Madan

Maybe you are looking for