Sorting table by columns

I have table with id and 4 measures: Id, M1, M2, M3, M4.
I want to present report with the top N ids - but I do not know what measure the user will want to sort by.
I can create 4 reports - each report X will present Id, M1, M2, M3, M4 and will have filter when Rank(max(Mx))<N.
a. I prefer create one report with some kind of column selector, but I could not add Rank(max(Mx)) to the selector - just Mx.
How can I do it?
b. If I will have the 4 different reports - I don't want to execute each time the 4 reports even if the user is interested only in one report.
How can have the option of asking the suer to select measure Mx and then execute only the desired report X?
Thanks,

Hi,
I will advice you to use RCOUNT(ID) instead of Rank.Try to implement the below steps and see if that helps
1)Create a dummy column in your report and add RCOUNT(ID) to its formula.
2)Lets say by default you have M1 in your report.Put a sort order according to your need i.e ascending or descending.
3)Now put a filter on RCOUNT as RCOUNT is in top or bottom 10 according to your need.
4)Put rest of the columns M2,M3,M4 in column selector created on M1.
In this way you dont need to create diffrent views or reports and you will be able to filter the records because filter criteria is based on ID which is not changing,
Thanks
Sandeep
Edited by: Sandeep Saini on 06-Sep-2010 09:32

Similar Messages

  • Sorting table view columns

    Hi ,
    In my application i want to sort specific tableview columns.When i am keeping Sort="server" .Now the hand point showing sort on every column.I wanted to restrict this to specific column.If you have information can you give how exactly sort option will work when sort by server and sort by application.
    Any weblogs available on sorting of tableview columns.
    Regards
    Usman

    Hi Usman,
    you can do this either with a tableview iterator or with the extension htmlb:tableviewcolumn.
    With the iterator you can change the behaviour of your columns in the method IF_HTMLB_TABLEVIEW_ITERATOR~GET_COLUMN_DEFINITIONS. The attribute P_COLUMN_DEFINITIONS is of type TABLEVIEWCONTROLTAB. With this attribute you can check "SORT" for a special column.
    With the extension htmlb:tableviewcolumn you can use the attribute SORT.
    Hoping this helps.
    Regards,
    Rainer

  • Sorting Table Column

    HI,
    I have a Webdynpro table with two columns, the first colum displays Company Names and the Second one Company Nodes.
    I would like to sort the fist column by Company Name and the second one by Company codes,
    i have gone through the following tutorial
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/c092333b-0601-0010-e7af-8c227fb6d052
    but its bit difficult to understand..
    is there any simple steps and code..
    Murali

    All that i did is excuted company code Bapi.
    public static void wdDoModifyView(IPrivateTableCompatibilityModeView wdThis, IPrivateTableCompatibilityModeView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
        //@@begin wdDoModifyView
              if (firstTime) {
                   IWDTable tablec = (IWDTable) view.getElement("CompanyTable");
                                  wdContext.currentContextElement().setTableSorter(
                                       new TableSorter(tablec, wdThis.wdGetSortByCompanyNameAction(), null));     
        //@@end
    ========================
    public void onActionsortByCompanyName(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
        //@@begin onActionsortByCompanyName(ServerEvent)
         wdContext.currentContextElement().getCCodeSorter().sort(
                        wdEvent,
                        wdContext
                             .nodeBapi_Companycode_Getlist_Input()
                             .nodeOutput()
                             .nodeCompanycode_List());
        //@@end
    after clicking on the header of the table following is the error stack
    =======================
    java.lang.NullPointerException
         at com.sap.tut.wd.tutwd_table.tablecomp.TableCompatibilityModeView.onActionsortByCompanyName(TableCompatibilityModeView.java:329)
         at com.sap.tut.wd.tutwd_table.tablecomp.wdp.InternalTableCompatibilityModeView.wdInvokeEventHandler(InternalTableCompatibilityModeView.java:318)
         at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
         at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:160)
    =================
    Message was edited by: Murali Manohar

  • Disable sorting and resizing columns on table view

    Is there a way to disable sorting and resizing columns on table view?
    Thanks

    Use
    setSortable(false)
    setResizable(false)
    on each TableColumn

  • Table Sorting based on Column Selection

    Dear All,
    I am using an AbstractTableModel. I would like to implement the sorting based on Column selection. Could anyone help me in this please.
    Thanks in advance,
    Regards
    Irfaan

    check this
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.UIManager;
    import javax.swing.table.AbstractTableModel;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumnModel;
    import java.awt.Component;
    import java.awt.GridLayout;
    import java.awt.Insets;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.util.Hashtable;
    public class TableSorter extends JPanel
        private boolean             DEBUG       = false;
        private Object[]            columnNames = { "First Name", "Last Name", "Sport", "# of Years",
                                                    "Vegetarian"};
        private Object[][]          data        = { { "Mary", "Campione", "Snowboarding", 1, 2 },
                { "Alison", "Huml", "Rowing", 3, 4 }, { "Kathy", "Walrath", "Knitting", 5, 9 },
                { "Sharon", "Zakhour", "Speed reading", 6, 10 }, { "Philip", "Milne", "Pool", 7, 11 },
                { "Isaac", "Rabinovitch", "Nitpicking", 8, 12 }, };
        private SortFilterModel     m_modSortFilterModel;
        private TableColumnModel    m_modColumnModel;
        private TableHeaderRenderer m_btnSorterRenderer;
        protected boolean           m_bAbCOC    = true;
        JTable                      table       = new JTable();
        public TableSorter()
            super(new GridLayout(1, 0));
            m_modSortFilterModel = new SortFilterModel();
            m_modSortFilterModel.addMouseListener(table);
            table.setModel(m_modSortFilterModel);
            m_btnSorterRenderer = new TableHeaderRenderer();
            m_modColumnModel = table.getColumnModel();
            for (int i = 0; i < columnNames.length; i++)
                m_modColumnModel.getColumn(i).setHeaderRenderer(m_btnSorterRenderer);
            JScrollPane scrollPane = new JScrollPane(table);
            add(scrollPane);
        private class SortFilterModel extends AbstractTableModel
            int[]           indexes;
            ATSTableSorter  sorter;
            public String[] tableHeadersArray;
            boolean         isAscent = true;
            public void addMouseListener(final JTable table)
                table.getTableHeader().addMouseListener(new MouseAdapter()
                    public void mouseClicked(MouseEvent event)
                        int tableColumn = table.columnAtPoint(event.getPoint());
                        m_btnSorterRenderer.setPressedColumn(tableColumn);
                        m_btnSorterRenderer.setSelectedColumn(tableColumn);
                        if (TableHeaderRenderer.DOWN == m_btnSorterRenderer.getState(tableColumn))
                            isAscent = true;
                        else
                            isAscent = false;
                        // translate to table model index and sort
                        int modelColumn = table.convertColumnIndexToModel(tableColumn);
                        sortByColumn(modelColumn, isAscent);
            public Object getValueAt(int row, int col)
                int rowIndex = row;
                if (indexes != null)
                    rowIndex = indexes[row];
                return data[rowIndex][col];
            public void setValueAt(Object value, int row, int col)
                int rowIndex = row;
                if (indexes != null)
                    rowIndex = indexes[row];
                super.setValueAt(value, rowIndex, col);
            public void sortByColumn(int column, boolean isAscent)
                if (sorter == null)
                    sorter = new ATSTableSorter(this);
                sorter.sort(column, isAscent);
                fireTableDataChanged();
            public int[] getIndexes()
                int n = getRowCount();
                if (indexes != null)
                    if (indexes.length == n)
                        return indexes;
                indexes = new int[n];
                for (int i = 0; i < n; i++)
                    indexes[i] = i;
                return indexes;
            public int getRowCount()
                return data.length;
            public String getColumnName(int c)
                return columnNames[c].toString();
            public int getColumnCount()
                return columnNames.length;
            public Class getColumnClass(int col)
                switch (col)
                case 0:
                    return String.class;
                case 1:
                    return String.class;
                case 2:
                    return String.class;
                case 3:
                    return Integer.class;
                case 4:
                    return Integer.class;
                          default:
                    return Object.class;
        class ATSTableSorter
            SortFilterModel model;
            public ATSTableSorter(SortFilterModel model)
                this.model = model;
            public void sort(int column, boolean isAscent)
                int n = model.getRowCount();
                int[] indexes = model.getIndexes();
                for (int i = 0; i < n - 1; i++)
                    int k = i;
                    for (int j = i + 1; j < n; j++)
                        if (isAscent)
                            if (compare(column, j, k) < 0)
                                k = j;
                        else
                            if (compare(column, j, k) > 0)
                                k = j;
                    int tmp = indexes;
    indexes[i] = indexes[k];
    indexes[k] = tmp;
    public int compare(int column, int row1, int row2)
    Object o1 = model.getValueAt(row1, column);
    Object o2 = model.getValueAt(row2, column);
    if (o1 == null && o2 == null)
    return 0;
    else if (o1 == null)
    return -1;
    else if (o2 == null)
    return 1;
    else
    Class type = model.getColumnClass(column);
    if (type.getSuperclass() == Number.class)
    return compare((Number) o1, (Number) o2);
    else if (type == String.class)
    return ((String) o1).compareTo((String) o2);
    else
    return ((String) o1).compareTo((String) o2);
    public int compare(Number o1, Number o2)
    double n1 = o1.doubleValue();
    double n2 = o2.doubleValue();
    if (n1 < n2)
    return -1;
    else if (n1 > n2)
    return 1;
    else
    return 0;
    class TableHeaderRenderer extends JButton implements TableCellRenderer
    public static final int NONE = 0;
    public static final int DOWN = 1;
    public static final int UP = 2;
    int pushedColumn;
    Hashtable state;
    public TableHeaderRenderer()
    pushedColumn = -1;
    state = new Hashtable();
    setMargin(new Insets(0, 0, 0, 0));
    setHorizontalTextPosition(LEFT);
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus,
    int row, int column)
    setText((value == null) ? "" : value.toString());
    setBorder(UIManager.getBorder("TableHeader.cellBorder"));
    boolean isPressed = (column == pushedColumn);
    getModel().setPressed(isPressed);
    getModel().setArmed(isPressed);
    return this;
    public void setPressedColumn(int col)
    pushedColumn = col;
    public void setSelectedColumn(int col)
    if (col < 0)
    return;
    Integer value = null;
    Object obj = state.get(new Integer(col));
    if (obj == null)
    value = new Integer(DOWN);
    else
    if (((Integer) obj).intValue() == DOWN)
    value = new Integer(UP);
    else
    value = new Integer(DOWN);
    state.clear();
    state.put(new Integer(col), value);
    public int getState(int col)
    int retValue;
    Object obj = state.get(new Integer(col));
    if (obj == null)
    retValue = NONE;
    else
    if (((Integer) obj).intValue() == DOWN)
    retValue = DOWN;
    else
    retValue = UP;
    return retValue;
    private static void createAndShowGUI()
    JFrame frame = new JFrame("TableDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TableSorter newContentPane = new TableSorter();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    createAndShowGUI();

  • Sorting table according 2 columns

    Hello,
    I am using the TableSorter object in order to sort Dynpro tables.
    Suppose I have requirement to sort according 2 columns,
    I mean one primary and second secondary.
    The situation now is every click on another column cancel the first sort.
    I'll appreciate any suggestion.
    Thanks,
    Maya.

    Hi Maya,
    Check this links.
    /people/bertram.ganz/blog/2006/03/07/enhanced-web-dynpro-java-tablesorter-for-sap-netweaver-04s
    Re: table column sorting
    Re: execute tableSorter
    Regards,
    Mithu

  • I can't sort a single column only (ignoring the next column)

    I can't sort a single column only (ignoring the next column) in NUMBERS

    Numbers sorting follows a database model in which each row is a 'record' rather than a collection of unrelated data items. When a table is sorted, the integrity of the individual records (rows) is maintained.
    If you need to sort a single column, that column (or its data) must be separated from the rest of the table.
    That can be done using copy/paste (as described above by Wayne), or by taking the column to be sorted out of the table, dropping it on the sheet to form a new, single column table, doing the sort, then returning the column to the original table.
    The 3 1/2 step process takes longer to describe than to do.
    Regards,
    Barry

  • Unable to sort table

    Hi all
    I have created an advance table and using multiple selection.I set Sort Allowed property 'Yes' for every column in property inspector.
    But when I clicked on cloumn it throws a warning "The table cannot be sorted because it has pending changes which would be lost." and I am not able to sort table.
    Can somebody give me some suggestions.
    Thanks
    Bhupendra

    I have createed sortable header.I have done this thing many times and it works.But this time only I m facing problem.I am using PPR in this table where I am enabling and disabling the checkbox.
    Please give suggestions if anybody has faced this problem.
    Thanks
    Bhupendra

  • How do I sort data in columns using Pages

    How do I sort data in columns (alphabetically) using Pages?

    If you are referring to text or numbers in a column (not table), then get the free Service plug-in WordService, from Devon Technologies. Put it in the
    /Users/yourlogin/Library/Services folder location.
    Select your data to be sorted. From the Pages menu > Services > Sort Ascending will do the trick. This will work with Pages ’09 and Pages v5.2 or later, as well as Apple Mail, TextEdit, etc.
    The WordService files include a PDF (Read Me) that describes the services included with the package.
    The Service items will only appear in the Services submenu when you have selected your data prior to sort. If these WordService items do not appear in the Services menu as they should per the preceding sentence, then you will need to enable them.
    System Preferences > Keyboard > Shortcuts > Services. Scroll through the right hand list of services until you encounter Sort Ascending and ensure that it is selected.
    If you were referring to sorting a column of data in a table:
    Pages ’09
    Select all cells containing your unordered data. In the Table Inspector, under Edit Rows & Columns, choose Sort Ascending.
    Pages v5.2
    Select cells as before. In the Table heading (A, B, C, etc.) when you roll over the letter, a down-arrow appears. Click, and choose Sort Ascending from the drop down menu.

  • Updating a sorted table when a cell editor is open

    In Sun's table sorter demo, if you are in the middle of editing a cell and you toggle the sort on any column, the editor automatically cancels the edit, closes the editor and the table sorts appropriately. I am guessing that the cancelEditing method on the editor is called somehow by the table when the table data changes.
    For some reason, in my application, when the sort is toggled, the editor remains open and does not cancel. As a result, when the table sorts, the value you are editing is not for the correct row anymore.
    The custom cell editors I am using are not the problem because I removed them and I still have this problem.
    Unfortunately, it would be extremely difficult for me to provide a sample application to demonstrate my problem because there is so much proprietary stuff mixed into my tables. I am hoping someone else is familiar with the problem I am having and can offer some solution.
    Thanks in advance for any assistance.

    Actually I do have this setup on the table and when sorting is toggled, the focus remains in the editor so it does not terminate.
    Any other possibilities?

  • Clicking the table header column programmatically

    Hi
    For sorting of the JTable I've used the TableSorter API provided in this site. What I need to do is by clicking on another panel the panel containing the JTable should be displayed sorting the respective column. So what I need to do is click the table header column programmatically. Do you know how can I do that.
    Thanx.

    Take a look at setSortingStatus function in TableSorter.
    If you want ascending sort just call:
    setSortingStatus(columnIndex, 1);This is the code executed when you press table header, it might give you some more insight:public void mouseClicked(MouseEvent e) {
                JTableHeader h = (JTableHeader) e.getSource();
                TableColumnModel columnModel = h.getColumnModel();
                int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                int column = columnModel.getColumn(viewColumn).getModelIndex();
                if (column != -1) {
                    int status = getSortingStatus(column);
                    if (!e.isControlDown()) {
                        cancelSorting();
                    // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                    // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                    status = status + (e.isShiftDown() ? -1 : 1);
                    status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                    setSortingStatus(column, status);
            }

  • SORT table of type ANY

    Hi,
        I've a internal table defined:
    DATA: <lt_result>  TYPE ANY TABLE.
    A table name is passed and its structure is assigned to it:
      CALL FUNCTION 'TREX_BUILD_COMP_DESCR'
        EXPORTING
          i_tabname    = lv_tabname
        IMPORTING
          e_comp_descr = lt_comp_descr[].
      lt_meta = cl_trex_table_meta=>create_by_comp_descr( lt_comp_descr ).
      lt_ref  = lt_meta->create_itab( ) .
      ls_ref = lt_meta->create_structure( ).
      ASSIGN lt_ref->* TO <lt_result>.
      ASSIGN ls_ref->* TO <ls_result>.
    After calling some function, i've the result table <lt_result> populated.
    Now, I want to sort it on a field of table.
    for example, i assiged to <lt_result>  structure of table ZCUST.
    ZCUST has a field guid_abc.
    I want to sort <lt_result> by guid_abc.
    How can i do it?
    Thanks,
    Rohit.

    Hi,
    SORT <lt_result> BY (COLUMN). " Use your column in brackets

  • How to disable table header column reordering

    Does anyone know how to disable reordering of some but not all columns in tableview ? For that matter how to disable reordering for all columns?
    Thanks in advance !

    The following code will disable sorting in all columns
    public static <S> void disableSort(TableView<S> table){
    Iterator<TableColumn<S,?>> columns = table.getColumns().iterator();
    while(columns.hasNext())
    columns.next().sortableProperty().set(false);
    }

  • How can I sort alphabetically three columns?

    Hi to everybody!
    I've got some problems sorting alphabetically three columns. If I try to sort one column it changes also the others. I want three independent columns and each of them must be sorted out alphabetically.
    In Excel it's so easy: I just have to select the column and push the button "sort the column alphabetically". Why is that so difficult in numbers?
    Check it out: http://yfrog.com/j6screenshot01tj

    l,
    What is the nature of the content in the three columns? If the content is just data, and not calculations or the input to calculations, you can easily accomplish a single column sort in Numbers.
    I see from your screen shot that you are still in the Excel mindset. You have a large table with more rows and columns empty than occupied. To work most effectively in Numbers we usually use only as many rows and columns as necessary, and if we have data that is of another set and not related, we begin a new table.
    So, if your data meets the requirements of the first paragraph and you have trimmed away the excess rows and columns we can do the following: Click once on the label of the column you wish to independently sort. Then click again on this label and drag it up and away from the table to a blank area of the canvas. Perform the sort on the separated column. Then grab the sorted column in the same way as before and move it over the original table, watching the borders between columns highlight as you move over them. The double line between columns identifies the insertion point. When you have your sorted column in the right place, drop it back into the original table.
    Jerry

  • Sort just one column

    Is it possible to just sort one column without all the other columns sorting? I want to be able to manipulate a list of students in different ways (orders) without the other column changing order. I ussed to used excel microsoft and I'm sure I was able to do this with that program. Does Numbers allow this?

    James,
    Copy the column that you wish to sort and Paste it to an open part of the Sheet's canvas. This will create a 1-column table. Sort it. Copy the sorted table and Paste it back where it came from. The easiest and most reliable way to Select an entire column for Copying or Pasting is to click on the column's Label.
    If you describe the entire table, it may be possible for us to suggest another approach.
    Jerry

Maybe you are looking for

  • Loginwindow startup delay

    I'm wondering if anyone else is experiencing this issue... Is there a way to delay the login window from starting up before the network services are available? I know there is an option in /Library/Preferences/com.apple.loginwindow.plist to use a "St

  • 2 files scenario design

    Hey guys, I have a simple interface where I need to get 2 files from an FTP directory, and then post it in SAP. Once both files are posted, I need to do an RFC call but only once. So the flow will be: FILE1 AND FILE2 --> PI --> FILE1 AND FILE2 IN SAP

  • ABAP Memory.

    Hi, I have 2 ABAP program which was created in dialog screen not selection-scrren and list-processing.  I using IMPORT & EXPORT with MEMORY ID 'mem_test' to pass value. I would like to know will there be any memory corruption and cause inconsistency

  • Setting sga_target in Oracle10g using spfile in Window OS

    Hi all Previously we used to set the parameter values thru initora Now we wish to follow the default spfile for parameters as provided by Oracle. When we give alter system set pga_aggregate_target = ???M; it works properly but the same syntex does no

  • Upgrade of portal dependencies

    Hi, I'm upgrading our portal environment from SP10 to SP14. We would like further development in new sofware components to be based on SP14 rather than SP10. But we also have many existing sofware components depending on SP10 components. What will ha