Database Reference
In-Depth Information
Sorting data based on other columns
When you add a column to a pivot table or to a slicer, by default, the data is sorted in
the ascending order either by digit or by character. This is what you can see on the
Month
attribute in the preceding screenshot. In a lot of cases, this is not what you
want to do; instead, you want to sort it based on another attribute, in the month ex-
ample, you typically want it sorted by the month number instead.
When working with multidimensional models, you can solve this by the
NameColumn
,
KeyColumn
, and
OrderBy
attributes of the attribute. However, in tabular models,
there is no concept of name and key columns; so how do you solve this?
In the first version of PowerPivot, there was no other option than to create an attribute
that looked like
01_January
to sort January as the first month. However, as one of
the new features in SQL Server 2012 the tabular model has an option to sort a column
by another column. This gives the developer the ability to mark a column as a sorting
column and it will be displayed correctly in the tools that are able to consume tabular
models.
In the
DimDate
table, in addition to the
EnglishMonthName
column, there is also a
MonthNumberOfYear
column. This is the column that you want to sort the months
by. Perform the follow steps to create the sorting:
1. Make sure that you are in
Grid
view in the designer.
2. Click on the
DimDate
tab.
3. Click on the
EnglishMonthName
column.
4. Then click on the
Sort by column
button.
5. In the dialog box, make sure that
EnglishMonthName
is specified under
Sort
and that
MonthNumberOfYear
is selected under the
By
section.
Search WWH ::
Custom Search