Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


MDX First month of year


MDX First month of year

Author
Message
robert.gerald.taylor
robert.gerald.taylor
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1326 Visits: 1399
This shouldn't be as hard as it seems; I want to always get the first month of the year (January) regardless of what month is the current member. I'm going to use this later on (if I get it to work) for a calculated member. The Date dimension's calendar hierarchy is Year --> Quarter --> Month.

So I've tried:


-- Returns back the year okay --
SELECT {} ON ROWS,
Ancestor([Date].[Calendar].CurrentMember, [Date].[Calendar].[Year]) ON COLUMNS
FROM [RoyaltyPMA]
WHERE [Date].[Month].&[201209];


But shouldn't this return back the first quarter of the year?:

-- Returns back nothing --
SELECT {} ON ROWS,
Ancestor([Date].[Calendar].CurrentMember, [Date].[Calendar].[Year]).FirstChild ON COLUMNS
FROM [RoyaltyPMA]
WHERE [Date].[Month].&[201209];


Or, couldn't I get the .FirstSibling of the .CurrentMember (if CurrentMember is at the month level) like. I've also unsuccessfully tried using the OpeningPeriod.

It must be too late at night; any pointing me in the correct direction would be appreciated.

Thanks,
Rob
robert.gerald.taylor
robert.gerald.taylor
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1326 Visits: 1399
I'm sure there must be a better way, but I did get this to work by:

MEMBER [Measures].[Yearly Adv Req] AS
(
Ancestor( [Date].[Calendar].CurrentMember, [Date].[Calendar].[Year] ).FirstChild.FirstChild,
[Measures].[Advertising Req]
)


Rob
Mackers
Mackers
SSC-Enthusiastic
SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)SSC-Enthusiastic (117 reputation)

Group: General Forum Members
Points: 117 Visits: 499
It's probably how I would have done it

Alternatively you could do

MEMBER [Measures].[Yearly Adv Req] AS   
(Descendants(Ancestor( [Date].[Calendar].CurrentMember, [Date].[Calendar].[Year] ),2).Item(0)
, [Measures].[Advertising Req] )


Mack
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search