dilluns, 26 de novembre del 2012

How to reverse crosstab rows order

By default, crosstab members order is set at Framework Manager or within the cube definition. So totals are always shown within a crosstab at the top position.

If you need to reverse crosstab members order follow the next steps:

Current hierarchy structure  vs  Desired hierarchy structure
Level 4                                          Level 6
  Level 5                                      Level 5
  Level 5                                        Level 6
    Level 6                                      Level 6
    Level 6                                    Level 5
  Level 5                                      Level 5
    Level 6                                  Level 4

0 - Create a dataitem and name it "Descendants" with the descendans of a member like
descendants(Member...,5,beforewithmember)
beforewithmember allows the crosstab to show the root nodes.

1 - Create a dataitem and name it 'Ordinal'. Put this expression
Ordinal(Level(currentMember(Hierarchy...)))
2 - Set the order using a dataitem, name it 'Order'. Set properties "Aggregate function" and "Rollup Aggregate function" to 'Count'.
2.1 - If you are using a dimensional model use the following expression
bottomCount([Descendants],50, [Ordinal] )

2.2 - If you are using a relational model use the following expression.
running-count()

3 - Change sorting options of the crosstab member. Drag and drop 'Order' dataitem and set sorting option as descending

2 comentaris:

  1. Hi,

    Thank you for a good idea!
    I tried to re-use it but it looks like it doesn't fully work.
    I managed to sort it like:
    Level5
    Level6
    Level5
    Level6
    Level6
    Level5
    Level5
    Level4
    Somehow the Level6 is below Level5 but should be above. Do you know what could be the reason?

    /W

    ResponElimina
  2. Hi Wojtek,

    Please send me your code and I'll have a look at it...
    What kind of model do you have, relational or dimensional?

    Kind regards,
    Raul Parra

    ResponElimina