US and Worldwide: +1 (866) 660-7555
Results 1 to 5 of 5

Thread: Mondrian seems to ignore FORMAT_STRING on time dimension calculated members

  1. #1
    Join Date
    May 2014
    Posts
    5

    Default Mondrian seems to ignore FORMAT_STRING on time dimension calculated members

    Hi,

    I have calculated member on the time dimension, to show a progression rate between two years. Of course, this rate should be expressed in %.
    But it seems my FORMAT_STRING is simply ignored, and the format of the measure the calcMember is applied to is used instead (using JPivot).

    Here is my calc member definition:
    with member [Temps.Temps par mois].[TAUX_ATTEINT] as '([Temps.Temps par mois].[2013] / [Temps.Temps par mois].[2012])', FORMAT_STRING = "Percent", MEMBER_CAPTION = "Ratio"

    When crossed with a measure with an integer format, it will display as an interger (so mostly 0).

    If I create a calculated member on the Measures dimension, then the format is taken into account just fine.

    Is the a known bug / limitation ? Is there a workaround ?

    Thanks in advance,
    Franck

  2. #2
    Join Date
    Jan 2013
    Posts
    510

    Default

    That should work. Is the measure in context also calculated? It's possible an intersecting calculation is overriding the format.

  3. #3
    Join Date
    May 2014
    Posts
    5

    Default

    Ok, after further investigation, I have found that this happens when the Measures member (on which the time calculated member applies) has a CellFormatter.
    Then this will take precedence over any FORMAT_STRING set on the calculated member.

    Here is the code, in RolapResult.executeStripe() :

    RolapMeasure m =(RolapMeasure) revaluator.getContext(measuresHierarchy);
    ValueFormatter valueFormatter = m.getFormatter();
    if (valueFormatter == null) {
    cachedFormatString = revaluator.getFormatString();
    Locale locale =
    statement.getMondrianConnection().getLocale();
    valueFormatter = formatValueFormatters.get(locale);
    if (valueFormatter == null) {
    valueFormatter = new FormatValueFormatter(locale);
    formatValueFormatters.put(locale, valueFormatter);
    }
    }

    Changing if(valueFormatter == null) into if(valueFormatter == null || revaluator.getFormatString() != null) will make the Percent format apply.
    But this changes the application behaviour, and it might not be the right thing to do...

    What do you think ?

  4. #4
    Join Date
    May 2014
    Posts
    5

    Default

    Finally, it seems that CellFormatter and FORMAT_STRING don't mix very well together. Moreover, CellFormatters seem to be simply ignored on non measures calculated members (as there class is not RolapCalculatedMember).

    We ended up with the ugly patch above, but there is certainly room for improvment on this matter in Mondrian...

    Regards,
    Franck

  5. #5
    Join Date
    Jan 2013
    Posts
    510

    Default

    Agreed, the two do not mix well together. I've created MONDRIAN-2118 to capture the issue. Please add to it if you have any comments (and vote for it).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •