dbTalk Databases Forums  

MDX date fix

comp.databases.olap comp.databases.olap


Discuss MDX date fix in the comp.databases.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dean
 
Posts: n/a

Default MDX date fix - 08-13-2003 , 10:23 AM






I have a date dimension which is broken into levels year month day,
then I have a measure called count, what I need to do is show the
measure count for all but the lastchild of each of the levels.
etc

Date [measures].[count]

-2003 (last child not shown)
- Jan 2
- Feb 4
- March (last child not shown)
- 1st 3
- 2nd 5
- 3rd 7
- 4th (last child not shown)

I tried writing something like

iif([Date].currentmember <> [date].currentmember.lastchild,
[measures].[count], null)

but this doesnt do anything so anyone have any ideas?
cheers
Dean

Reply With Quote
  #2  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX date fix - 08-17-2003 , 12:03 AM






"Dean" <dean.shackley (AT) logicacmg (DOT) com> wrote

Quote:
I have a date dimension which is broken into levels year month day,
then I have a measure called count, what I need to do is show the
measure count for all but the lastchild of each of the levels.
etc

Date [measures].[count]

-2003 (last child not shown)
- Jan 2
- Feb 4
- March (last child not shown)
- 1st 3
- 2nd 5
- 3rd 7
- 4th (last child not shown)

I tried writing something like

iif([Date].currentmember <> [date].currentmember.lastchild,
[measures].[count], null)

but this doesnt do anything so anyone have any ideas?
cheers
Dean
This can be done by using either new calculated member and hiding the
measure [count], or by calculated cell.
I assume you have chosen calculated member approach. Then the expression
could look like

IIF( [Date].CurrentMember IS [Date].Parent.LastChild, NULL,
Measures.[Count] )

Two notes:

1. Operator "=", "<>" etc will compare _values_ of the cells, not the
members. To compare members use "IS" operators (possibly with conjunction
with "NOT" operator).
2. I assumed, that [Date] dimension has All level, therefore Parent of
[2002] is [All Dates]. Otherwise, there will have to be special test for the
first level, since .Parent will return NULL member for it.

HTH,
Mosha

==================================================
Mosha Pasumansky - www.mosha.com/msolap
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==================================================




Reply With Quote
  #3  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX date fix - 08-18-2003 , 10:40 PM



"Dean" <dean.shackley (AT) logicacmg (DOT) com> wrote

Quote:
Hi Mosha
thanks for your reply, I was aware of the is operator but when I
wrote the code

IIF( [Date monthly].CurrentMember IS [Date monthly].Parent.LastChild,
NULL,
Measures.[Carried Forward] )

using calculated member builder I got the error invalid token "IS" so
I was not sure I was using it in the right context
Dean, I just tried this expression in the Foodmart

with member measures.x as 'iif(Time.CurrentMember is Time.Parent.LastChild,
NULL, [Measures].[Units Shipped])'
select {x} on 0 from warehouse
where [Time].[1997].[Q3]

and it worked fine.
You are using Analysis Services 2000, not OLAP Services 7.0, right ?

--
==================================================
Mosha Pasumansky - www.mosha.com/msolap
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==================================================




Reply With Quote
  #4  
Old   
Mosha Pasumansky [MS]
 
Posts: n/a

Default Re: MDX date fix - 08-28-2003 , 03:21 PM



Quote:
I have now found a solution to the problem using

iif([date monthly].currentmember.properties("ID") = [date
monthly].currentmember.parent.lastchild.properties("ID"), 1, 0)
Simpler boolean expression would be simply

[date monthly].currentmember.properties("ID") = [date
monthly].currentmember.parent.lastchild.properties("ID")

Quote:
now the problem is i only dont want to show the measure for the last
child of each level so currentmember.parent.lastchild does not work as
it will not show the measure for the last day in each month.

so I need to say something like [date].[day].members.lastchild but you
can not use lastchild with a set so any suggestions
There are several ways to do it. For example

Tail([date].[day].members, 1).Item(0)

should produce last day.

HTH,
Mosha.

--
==================================================
Mosha Pasumansky - www.mosha.com/msolap
Development Lead in the Analysis Server team
All you need is love (John Lennon)
Disclaimer : This posting is provided "AS IS" with no warranties, and
confers no rights.
==================================================




Reply With Quote
  #5  
Old   
Dean
 
Posts: n/a

Default Re: MDX date fix - 09-01-2003 , 04:01 AM



"Mosha Pasumansky [MS]" <moshap (AT) microsoft (DOT) com> wrote

Quote:
I have now found a solution to the problem using

iif([date monthly].currentmember.properties("ID") = [date
monthly].currentmember.parent.lastchild.properties("ID"), 1, 0)

Simpler boolean expression would be simply

[date monthly].currentmember.properties("ID") = [date
monthly].currentmember.parent.lastchild.properties("ID")

now the problem is i only dont want to show the measure for the last
child of each level so currentmember.parent.lastchild does not work as
it will not show the measure for the last day in each month.

so I need to say something like [date].[day].members.lastchild but you
can not use lastchild with a set so any suggestions

There are several ways to do it. For example

Tail([date].[day].members, 1).Item(0)

should produce last day.

HTH,
Mosha.
thanks Mosha, worked ace!


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.