[Mondrian] International number formats

Luc Boudreau lucboudreau at gmail.com
Thu Jul 29 09:36:12 EDT 2010


Hello,

I'm currently working on adding a nice feature to Mondrian; supporting
different formatting for thousand separators for different countries. An
easy example would be the Indian formatting for currency. A ten million
dollars must be displayed as :

$1,00,00,000.00

As you can see, the first 3 whole numbers are grouped, while the remaining
digits are grouped by two.

Mondrian code was applying a modulo of 3 to the position of the digits and
didn't consider the actual position of the thousand separator in the format
string you passed, thus making any such formatting impossible. I found a
nice way to support this, but there are repercussions that I would like to
discuss.

First, the test suite has some measures in the Sales cube that have the
format string "#,#". The old code would interpret this as "no decimals, and
commas to split the thousands every 3 digits". In the new code, that would
be interpreted as "no decimals, a separator every digit". In my opinion, the
new code makes a much better job at interpreting that format string. Once
you get down to really thinking about what #,# means, and you consider other
formats like "#,###", it definitely makes sense.

That "#,#" appears in:

<Measure name="Count" column="employee_id" aggregator="count"
      formatString="#,#"/>
  <Measure name="Number of Employees" column="employee_id"
      aggregator="distinct-count" formatString="#,#"/>

Some tests are coded to look for those format strings.

mondrian.xmla.XmlaCognosTest<eclipse-javadoc:%E2%98%82=mondrian-2.0/testsrc%5C/main%3Cmondrian.xmla%7BXmlaCognosTest.java%E2%98%83XmlaCognosTest>.testCognosMDXSuiteHR_001()

mondrian.xmla.XmlaCognosTest<eclipse-javadoc:%E2%98%82=mondrian-2.0/testsrc%5C/main%3Cmondrian.xmla%7BXmlaCognosTest.java%E2%98%83XmlaCognosTest>.testCognosMDXSuiteHR_002()


I propose to change them to "#,###" and make my implementation of the format
string the official one for Mondrian. Here are some examples of how I would
like the format strings to be interpreted. The base number is 1234567.8.

#,###            1,234,567
######,##,##.00  123,45,67.80
#,#              1,2,3,4,5,6,7
##,##,##,###.#   12,34,567.8


_____________________________
Luc Boudreau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20100729/33693bde/attachment.html 


More information about the Mondrian mailing list