[Mondrian] First Day of Week - CurrentDateMember

Paul Stoellberger p.stoellberger at gmail.com
Fri Nov 28 06:42:04 EST 2014

I had a quick look at this

a) for format FORMAT_DD and FORMAT_DDD you use the FormatData - days of week etc. coming from sun.text.resources.FormatData - which could be passed via resource file afaik somehow, dont fully understand how but still.

b) The issue is that all other date formats - in this case FORMAT_W and FORMAT_WW - uses DateFormat in FormatLocale
But in fact the CurrentDateMemberUdf calls format(Date,..) which goes via BasicFormat, which doesn’t respect the Locale

Calendar calendar = Calendar.getInstance(); // todo: use locale

As the TODO says already, it doesn’t respect the locale, which would be a start (FormatLocale is set properly for mondrian in Diethards case)

We could just extend DateFormat to respect the Locale

I think this would be better than adding this to the BasicFormat itself - as its supposed to be very basic as I understand it.

However, since CurrentDateMember is a heavily used function, it would probably break a lot of existing MDX if we would suddenly respect the locale properly for dates.
Can you think of a less intrusive approach that would make options like that configurable?
General Calendar locale and even if you use the right locale, still make firstDayOfWeek etc. options to configure?


On 27 Nov 2014, at 22:47, Julian Hyde <julianhyde at gmail.com> wrote:

> I added a lot of locale-specific stuff (e.g. currency) to mondrian.util.Format.FormatLocale.
> It gleans as much as it can from the java.util.Locale. IIRC there is also a way of putting the information in a locale resource file.
> It wouldn’t be that hard to add first-day-of-week to FormatLocale. Then I believe CurrentDateMember would inherit it (because it uses Format under the covers).
> Julian
>> On Nov 26, 2014, at 2:11 AM, Diethard Steiner <diethard.steiner at gmail.com> wrote:
>> Hi,
>> As far as I understood the formatting string for CurrentDateMember is based on the Visual Basic Syntax. This one seems to only provide one formatting option for day of week, and this one is based on a week starting on a Sunday. Over here in Europe, the week starts on a Monday, in other parts of the world on Thursday and so on. This has an impact on how you use in example the Lag() function. In example:
>>     [Measures].[Count Subscribers] ON 0
>>     , NON EMPTY( ( CurrentDateMember([Activation Date.Weekly Calendar],"[""Activation Date.Weekly Calendar""]\.[yyyy]\.[ww]\.[w]").Lag(21) : CurrentDateMember([Activation Date.Weekly Calendar],"[""Activation Date.Weekly Calendar""]\.[yyyy]\.[ww]\.[w]").Lag(2)) ON 1
>> FROM [Subscriber]
>> Today is Wednesday, the third day of week according to the European standard, however the format string in the query above will return 4 because it is based on the US standard. Hence to get data up to yesterday, I have to use Lag(2) instead of Lag(1). Now this is not a massive problem, but not ideal either. I wonder if there is a global Mondrian setting which allows to define the start of the week (maybe something similar as outlined here: http://msdn.microsoft.com/en-us/library/20ee97hz(v=vs.90).aspx), so that the formatting string result is based on this.
>> Best regards,
>> Diethard
>> _______________________________________________
>> Mondrian mailing list
>> Mondrian at pentaho.org
>> http://lists.pentaho.org/mailman/listinfo/mondrian
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.pentaho.org/pipermail/mondrian/attachments/20141128/01a9fb02/attachment.html 

More information about the Mondrian mailing list