Sorting

Posted by: jorgecheve on 3 August 2017, 3:49 pm EST

  • Posted 3 August 2017, 3:49 pm EST

    With disconnected cube files, can I sort columns?
  • Replied 3 August 2017, 3:49 pm EST

    Below is what I found in Help --


     


    You can add sorting functionality to your applications to make referencing and comparing data easier for your users. For example, sorting a list of names or purchase orders alphabetically is generally the best data sequence for tables where the user will be exploring data associated with each name or order number. Chronological order is usually the best order for sorting dates and times allowing users to look up data based on the passage of time. These sorts are defined as computed sorts because they use programmatic rules that you define to sort the field.





    Sort Order


    The sort order determines how the data in the analysis view is sorted. The sort order can be set to either none, ascending or descending. By default, the sort order is set to ascending, and continuous fields are sorted from lowest number to highest number (as defined by the axes). You can reverse the order of an axis using field specific formatting. Use the Attribute class SortOrder property to set the sort order programmatically as shown in the following example.


     

    Code Sample




    Sort By


    In order to display the results in the most meaningful way, Data Dynamics provides a means of defining various sorting algorithms. The  class  property provides the options for setting the Sort By criteria. 
















    Sort by CriteriaDescription
    CaptionSorts a Member object by its Caption property.
    KeySorts a Member object by the member's underlying value. This is useful for when you provide your own captions 
    ExpressionSorts the data based on the results of a measure's values.



    Using the , you can add programmatically to your applications SortBy options as shown in the following example.


     

    Code Sample
  • Replied 3 August 2017, 3:49 pm EST

    DD,


      Some code examples on sorting would be great because they were left out of the documentation.


    Thanks


     

  • Replied 3 August 2017, 3:49 pm EST

    Jorgecheve,
    The simple answer to this question is yes.  You can perform sorting on disconneced cubes.  As Dan was kind enough to point out from the help documentation, there are 3 ways you can perform sorting on a field by: its key, its caption, or an expression.  Also you have 3 options for the order in which to sort the field: ascending, decending, and none.  These options can be set by using the menu that drops down when clicking on the trinagle of (or by right clicking anywhere on) an attribute field on a shelf (the only difference is that there is a "Field" SortBy option in place of the Expression option under the More Sort Options Dialog accessible from the menu).

    Dan,
    Soring can currently be applied by setting the SortOrder and SortBy properties (as you mentioned from the helpfile) of a DataView.PlainAttribute, or DataView.Level object that corresponds to a field in the current view.  You should only need to specifiy the SortExpression if you set the SortBy property to Expression. The following C# code sample demonstrates appling a Descending sort to a fields caption before adding it to the RowShelf:

                ViewDefinition model = pivotView1.InternalModel;
                ITransaction transaction = model.CreateTransaction("Sorting");
                PlainAttribute field = (PlainAttribute)model.CreateField(FieldTypes.Attribute, "[Product].[Category]");
                field.SortOrder = DataDynamics.Analysis.DataViewModel.SortOrder.Descending;
                field.SortBy = SortAttributeBy.Caption;
                model.RowShelf.Add(field);
                transaction.Commit();

    If you have any further questions, please feel free to let me know.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels