3
votes

This MDX function raise error :

with member measures.x as 
(
     [Date].[Date].[Date].&[20160101] : [Date].[Date].[Date].currentmember.value
    ,
    [Measures].[current balance]
)

select  measures.x  on columns,
[Branch].[HeadOffice Branch].[Head Office Code] on rows
from MyCube

Error is : The CURRENTMEMBER function expects a hierarchy expression for the 1 argument. A member expression was used.

But when I use [Date].[Date].[Date].&[20160101] : [Date].[Date].[Date].&[20160131] It works good

why?

2
hi - you might want to post another question detailing what you're trying to achieve with this script as I'm unsure of your reason for the use of currentmember. Are you trying to get today's date? (If you're just exploring - d3efinitely a good thing with mdx - then just ignore me)whytheq

2 Answers

2
votes

This is valid mdx:

[Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember

Although this is not:

WITH member measures.x AS
  (
     [Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember
    ,
    [Measures].[current balance]
  )

It is not valid because round braces (...) signify a tuple but a tuple requires exact co-ordinates so the first argument cannot be a set.

You could add an aggregation such as SUM:

WITH member measures.x AS
  SUM 
   (
     [Date].[Date].[Date].&[20160101] : [Date].[Date].currentmember
    ,
    [Measures].[current balance]
   )

This is valid mdx but if you do not have [Date].[Date] in context i.e. in the WHERE or SELECT clause then all it is returning is the All member.

Why are you using [Date].[Date].currentmember ?

1
votes

CURRENTMEMBER works on an attribute hierarchy (in your case [Date].[Date]). So [Date].[Date].CURRENTMEMBER will work.

Also you will need to take out the value selector, as your expression returns a set of dates (member : member returns a set of all the members between those two members).