We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

How to make the pivotgrid sort by members as numbers not as strings

Answered
mstrukov asked on August 11, 2016

We have a few dimensions with numeric members and we would like pivotgrid to sort them as numbers not as strings.
For example, the members values are 1, 2, 10, 12. If we sort them from A to Z the result is 1, 10, 12, 2. That is the sort is done as if the values were strings.
The sort result we expect is 1, 2, 10, 12. Is ther eanything we can do to achieve this? 
 
Note we use flash pivot grid version with CSV datasource.
 
Thank you!

4 answers

Public
Dmytro Zvazhii Dmytro Zvazhii Flexmonster August 12, 2016

Hi!
You should define dimension as numeric
Please find sample here: https://jsfiddle.net/yc3vto22/7/

Does it work for you?

Public
mstrukov August 19, 2016

We use a config file to set up report metadata. Is there a config file example?

Public
Iryna Kulchytska Iryna Kulchytska Flexmonster August 22, 2016

Hi Maxim,
 
The above sample was for JSON data source. Here I will explain you how to define data types in CSV.
Please note that the indication whether the dimension's members are numeric or string should be done in CSV, not in a config XML file. This can be done by using prefixes in the first CSV row. For example, "m+" prefix indicates that the field is a month:

amount,index,m+month,year
64685516,1,Feb,2015
1200000,2,Apr,2015
68640001,10,Jan,2014
31,11,Jan,2014

The fields "amount", "index" and "year" will be considered by the component as numeric automatically, based on the first members. There are some cases when you need to indicate that the field is numeric explicitly, for example, when the member in the first data row in CSV in null. In this case, "-" prefix should be used, as follows:

amount,-index,m+month,year
64685516,,Feb,2015
1200000,2,Apr,2015
68640001,10,Jan,2014
31,11,Jan,2014

More details about CSV data types can be found in the documentation https://www.flexmonster.com/doc/managing-data-presentation-csv/
 
Please let me know if the above approach works for you.
 
Kind regards,
Iryna
 

Public
mstrukov August 22, 2016

Hi Iryna,
Thanks for you answer I will give it a try soon

Please login or Register to Submit Answer