🍉 Meet Flexmonster Pivot Table & Charts 2.9.Check out all the hot features!
Get Free Trial

Sort on inactive dimensions

Jan Strohbehn asked on October 12, 2016


We offer our users pre-defined reports with inactive dimensions they can activate at their convenience. This works great and we are quite happy. But unfortunately we can not pre-define the custom-sorting on measures. In our example below ‘L4L’ is properly sorted, but if a user adds ‘Day of Week’ as row or column it get sorted alphabetically. What is the best way to deal with it?  

Thanks in advance for your support.

rows: [
{uniqueName: "L4L", customSorting: ["Existing", "New", "Closed"]},
{uniqueName: "Country"},
{uniqueName: "Own-Store"},
{uniqueName: "Retailmanager", active: false},
{uniqueName: "Store"}
columns: [
{uniqueName: "[Measures]"}
measures: [
uniqueName: 'Day of Week',
calculated: false,
caption: 'Day of Week',
customSorting: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
active: false
uniqueName: 'CS',
calculated: false,
aggregation: 'sum',
caption: 'Consumer Sales',
format: 'euro',
active: true
uniqueName: 'CS NET',
calculated: false,
aggregation: 'sum',
caption: 'Consumer Sales',
format: 'euro',
active: false

2 answers

Iryna Kulchytska Iryna Kulchytska Flexmonster October 28, 2016

Hi Jan,  

Thank you for writing your question here.
The property customSorting works for hierarchies in rows, columns and pages. Unfortunately, it does not work in measures. I have prepared a sample for you that illustrates how the days of the week can be sorted properly https://jsfiddle.net/irynakulchytska/a3387xth/. The component supports the sorting of months and the days of the week. The sample is based on JSON data and the first element of the JSON is used to define the data types:

"L4L": { type: "string" },
"Country": { type: "string" },
"Store": { type: "string" },
"Day of Week": { type: "weekday" },
"CS": { type: "number" },
"CS NET": { type: "number" }

More details about data types in JSON can be found in the following article in the documentation http://www.flexmonster.com/doc/data-types-in-json/. If your data source is CSV, please read about defining the data types in CSV http://www.flexmonster.com/doc/data-types-in-csv/.   By default, the days of the week are sorted according to the following order: “Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”. This order can be changed in a localization file. The following line in the sample defines the localization for the report:

localSettingsUrl: "https://s3.amazonaws.com/flexmonster/2.2/loc-en-workdays-order.xml"

Inside the localization file the block <weekdays> defines the following order: “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”.   If you need to pre-define the custom-sorting for hierarchies that have string data, like “L4L”: { type: “string” }, you need to select them for rows, columns or pages.   Please let me know if the above information was helpful.  

Kind regards,

Tanya Gryshko Tanya Gryshko Flexmonster November 25, 2016

Hello Jan and all Flexmonster users,
Please have a look at our updated recommendations after the release of version 2.3. Now localization is set via JSON. You can read more in localization article.
Check the updated sample: https://jsfiddle.net/flexmonster/uhnx6enz/
The localization for the report is defined this way:

localization: "loc/fr.json"

Also, customSorting property was renamed to sortOrder.

Please login or Register to Submit Answer