Search code examples
mdxiccube

CREATE SET in Script error - 'is neither a dimension or a hierarchy within the cube'


I'm trying to create a SET in the Script use case of icCube's Schema Manager:

CREATE SET [TOP_10_SALES] AS
    TopCount([BRAND].members - [BRAND].all, 10, [Measures].[Sales])

When I use this set in the reporting, I get the following error message:

'set([TOP_10_SALES]) : [Measures].[Sales] is neither a dimension or a hierarchy within the cube.'

If I put the same set in the WITH clause of the widget it works fine, but I'd really like to define that set only once in the schema manager instead of in each widget.


Solution

  • The script context is different from a query one. In the query context the cube name is known, this is not the case for the script. I guess your schema has more than one cube.

    You've to add the cube to the definition like this :

    CREATE SET [MyCube].[TOP_10_SALES] AS    
               TopCount([BRAND].members - [BRAND].all, 10, [Measures].[Sales])
    

    Since version 6.8 if you've a single cube in you schema you can directly write

    CREATE SET [TOP_10_SALES] AS ([BRAND].members - [BRAND].all, 10, [Measures].[Sales])