blogs.conchango.com

welcome to the conchango blogging site
Welcome to blogs.conchango.com Sign in | Join | Help
in Search

SSIS Junkie

Shifting data in a northern accent

Interested in working at Conchango? Email me

IM me Get alerted when a new blog entry is posted Windows Live Alerts Translate this page

MDX: Getting the current quarter

I've been wrestling with MDX in PerformancePoint today and was attempting to do something that I thought would be pretty simple. Work out what is the current quarter. No amount of googling turned anything up either.

It took me a while to figure out so I thought I'd post it up here in case I need it again or if anyone else ever needs it.

member [Time].[Calendar YQM View].[Current Quarter] as 'StrToMember("[Time].[Calendar YQM View].[Month].[" + Format(Now(), "MMM") + " Year " + Format(Now(), "yyyy") + "].Parent")'

There doesn't seem to be a format string that, when used with VBA's Format() function, will return the current quarter which seems, to me, to be a glaring omission. Hence I had to get the current month and ask for its parent.

Obviously you'll need to mess about with some string manipulation to suit whatever format you are using. In my case the label for the current month looks like this: "May Year 2008" which (I think) is PerformancePoint's doing. It seems utterly ridiculous to me. Surely "May 08", "May 2008" or even "200805" would be better? Still, who am I to complain.

Hope this helps. if anyone knows a better way feel free to let me know.

-Jamie

Published 07 May 2008 13:55 by jamie.thomson
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Ify said:

Why don’t you use the datepart function instead datepart(“q”,now()), Format function does not work for quarters.

You can use Ctsr(datepart("q",now())) to return a string like the format function

May 7, 2008 14:37
 

Ify said:

Noticed a syntax error. Correct syntax -> Cstr(datepart("q",now()))

May 7, 2008 14:42
 

Randy said:

Based on experience with Proclarity, the month/year name that you indicate is "May Year 2008" would come from the cube definition (SSAS) and not PerformancePoint itself. Not having worked with PerformancePoint, I could be wrong, but you might want to check with the cube designers if you want a change to that format.

May 7, 2008 17:24
 

jamie.thomson said:

Hi Randy,

Yes,you're absolutely correct. It exists in SSAS. However, those structures within SSAS are designed in PerfPoint, and since I wrote this I've been able to determine exactly where. These naming conventions are the defaults...strange defaults though.

-Jamie

May 7, 2008 17:30
 

Nat said:

Hi Jamie,

Mosha blogged about this a little while ago (see http://www.sqljunkies.com/WebLog/mosha/archive/2007/05/22/current_date_mdx.aspx).

After debating various options, Mosha concludes that: "[...] So the best solution, which is also the simplest one in terms of MDX, is to have a dedicated process, which will update MDX Script daily with the following line:

CREATE SET Today AS { [Date].[Calendar].[Date].[May 21, 2003] };

Where the name of today's date is hardcoded and changed every day. This will have the best performance, but it will also add a little management burden on the cube maintainer."

Obviously in your case the current quarter value would only need to be updated on a quaterly basis.

May 7, 2008 17:46
 

Thomas Ivarsson said:

Hello Jamie! Why did not the time intelligence that you configure with the data source, work? This is a feature in PP M&A.

May 7, 2008 17:47
 

Thomas Ivarsson said:

Sorry! Why can you not use ..

Mosha blog entry, pointed to by Nat is also good.

/Thomas

May 7, 2008 17:53
 

jamie.thomson said:

Hi Nat,

Interesting idea (and a good blog post from Mosha). I might look to implement that.

Thomas,

What is PP M&A?

Thanks

Jamie

May 7, 2008 18:09
 

Thomas Ivarsson said:

Performance Point Monitoring and Analytics!

Thomas

May 7, 2008 18:13
 

jamie.thomson said:

Aha. That's not what we're using though Thomas. We're using perfPoint planning.

May 7, 2008 18:19
 

Thomas Ivarsson said:

May 7, 2008 18:20
 

Thomas Ivarsson said:

OK! I have not used planning yet.

May 7, 2008 18:21
 

Peter Eb. said:

In planning we have the concept of $CurrentPeriod$ which is even more powerful than actual date... So that you can vary the $CurrentPeriod$ by model and by business process -- if you are capturing data entry for the last period even though you are past that time frame in the real world.

if you look at the mdx the addin generates for this when you make current period references you won't have to do string parsing.

May 7, 2008 22:32
 

Nick Barclay said:

Hi Jamie,

I agree that "May Year 2008" looks rediculous. However, you were given the chance to alter the format of the members in the time dimension when you created the application calendar in the "Define Period Naming Conventions" step.

Cheers,

Nick

May 7, 2008 23:26
 

jamie.thomson said:

Nick,

yeah I realise that now. Can I use the caveat "It weren't me that built the model, guv"? :)    Its actually true, someone else built it.

Anyway, I still say its a daft default.

-Jamie

May 8, 2008 10:42
 

Steve Walker said:

If you were at a large oil company, for example, we'd ask you to write 187 different web services to return current quarter.  Ideally in C or C++.  

May 8, 2008 23:45

Leave a Comment

(required) 
(optional)
(required) 
Submit

This Blog

Syndication

News

Powered by Community Server (Personal Edition), by Telligent Systems