Number Format

Help
2007-07-13
2013-04-29
  • Rodrigo Haces

    Rodrigo Haces - 2007-07-13

    Hi, i'm new using mondrian and jpivot. I have already create a cube, and cans ee it in my jpivot, but the number format is with the wrong locale, in mexico we use "#,###.##" (Thousands separeted by "," and decimals by ".") but i see numbers like "297.973.857".

    My cube schema has the correct format:

    <Measure name="Debe" column="debe" aggregator="sum" datatype="Integer" formatString="#,##0"/>
    <Measure name="Haber" column="haber" aggregator="sum" datatype="Integer" formatString="#,##0"/>

    How can i tell jpivot to use the correct number format?

    Thansk

     
    • Julian Hyde

      Julian Hyde - 2007-07-15

      This should work, provided that your locale is es_MX. There's even a test for it in RolapConnectionTest.java:

          public void testFormatLocale() {
              String expr = "FORMAT(1234.56, \&quot;#,##.#\&quot;)";
              checkLocale("es_ES", expr, "1.234,6", false);
              checkLocale("es_MX", expr, "1,234.6", false);
              checkLocale("en_US", expr, "1,234.6", false);
          }

      Try using an explicit 'Locale=es_MX' in the connect string.

      Julian

       
    • Rodrigo Haces

      Rodrigo Haces - 2007-07-16

      This is my mondrianquery at my jsp file:
      <jp:mondrianQuery id="query01" jdbcDriver="com.mysql.jdbc.Driver" jdbcUrl="jdbc:mysql://10.9.189.6:3306/olap?user=USR&password=PASS" catalogUri="/WEB-INF/queries/resultados.mondrian.xml">

      Is there where i shoudl add the Locale=es_MX? if so, i got an error that this propertyu is not defined, should i add it to the mondrian.properties file? or where?

      sorry for this, im really newbe

       
      • Julian Hyde

        Julian Hyde - 2007-07-16

        Since jpivot builds the mondrian connect string behind the scenes, from the attributes of that jp:mondrianQuery tag, I don't know how you would pass it in.

        I would hope that jpivot passes in the locale which came from your browser in the HTTP headers, but I don't know for sure whether that happens.

        Maybe some jpivot developers can step in here.

        Julian

         
    • Rodrigo Haces

      Rodrigo Haces - 2007-07-19

      Just to let all of you know how i solved this. Indeed, as Julian said, Jpivot passes the browser locale to mondrian but at the jpivot connection string, there is an option, dynLocale and dynResolver, the problem is that if in this i set dynLocale="es_MX" (or anything else) it doesnt change the locales, so my java expert and i went trough the jpivot source and noticed that at the jpivot.jar, pakage com.tonbeller.jpivot.mondrian, Class MondrianModel.java, Line 485, it is set this:

      // do we have a special locale setting?
      //if yes, promote it to the connection
      loc = getLocale(); // Locale.GERMANY
      if (loc != null) {
        if (logInfo) {
          String msg = "Locale language=" + loc.getLanguage() + " Country=" + loc.getCountry();
          logger.info(msg);
        }
        ((RolapConnection) monConnection).setLocale(loc);
      }

      So with this i noticed that the dynlocale parameter already set at the connection is changed here, so what i did is comment out this lines, build the jar and there we go, jpivot now sends the locale i stablish at dynlocale to mondrian.

      Thanks All

       
    • khandur

      khandur - 2008-02-14

      I´ve a similar question. My numbers are formated like "1,111,111.11" and I wanna to see the numbers like these: "1.111.111,11".

      My Jpivot/Mondrian tag is like this:

          <jp:mondrianQuery dynLocale="pt_BR" id="query01" ...

      And I´ve commented that lines in MondrianModel.java, like Rodrigo Haces does.

      Anyone can help me?

      Thanks!
      PS: I´m using JPivot 1.5

       
    • khandur

      khandur - 2008-02-29

      Hi!

      Just updating my JPivot to 1.7 number formatation works fine.

      Thanks people!

       
  • Anonymous - 2011-06-20

    Hi. I just did exactly what you said and everything works fine for now, but the only difference is that i did not set the dynLocale="es_PE" parameter in the query tag.

    Do you now what would be?

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks