Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MDX query not accepting date values

I'm a SSAS newbie and i'm trying to query a cube to retrieve data against aome measure groups order by date. The date range i wish to specify in my query. The query I'm using is this:-

SELECT
{
    [Measures].[Measure1],
    [Measures].[Measure2],
    [Measures].[Measure3]
} 
ON COLUMNS,
NON EMPTY{
   [Date].[AllMembers]
         } 
ON ROWS
FROM (SELECT ( STRTOMEMBER('2/23/2013', CONSTRAINED) : 
STRTOMEMBER('3/1/2013', CONSTRAINED) ) ON COLUMNS 
FROM   [MyCube])

However it gives me the following error
Query (10, 16) The restrictions imposed by the CONSTRAINED flag in the STRTOMEMBER function were violated.

I tried removing the constrained keyword and then even strtomember function. But in each cases i got the following errors respectively
Query (10, 16) The STRTOMEMBER function expects a member expression for the 1 argument. A string or numeric expression was used.
and
*Query (10, 14) The : function expects a member expression for the 1 argument. A string or numeric expression was used. *

I can understand from the last two errors that i need to include the constraint keyword. But can anyone tell me why this query wont execute?

like image 630
Sparky Avatar asked Sep 06 '25 03:09

Sparky


1 Answers

The string that you pass as the member expression must be a fully-qualified member name, or resolve to one. Use the same format as you did in the SELECT.

For example:

STRTOMEMBER('[Date].[2/23/2013]', CONSTRAINED)

Edit: I just noticed the syntax of your range select looks wrong -- you need to use {...}, not (...).

SELECT { 
    STRTOMEMBER('2/23/2013', CONSTRAINED) : 
    STRTOMEMBER('3/1/2013', CONSTRAINED) }
like image 200
findango Avatar answered Sep 08 '25 09:09

findango