Question

The following query works perfectly in SSMS, though it doesn't work in Query-designer due to the fact that I have a dimension defined on my COLUMNS-axis:

SELECT 
    NON EMPTY { 
        [Measures].[Amount]
        * [Cost Type].[Cost Type].[Cost Type]
    } ON COLUMNS
    , NON EMPTY { 
        [Empl].[Name].[Name]
        * [Date].[Calendar].[Month]
    } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM 
    Cube

To work around this, I've flattened the query in the following way:

SELECT t.* 
FROM (

    SELECT 
        NON EMPTY { 
            [Measures].[Amount]
            * [Cost Type].[Cost Type].[Cost Type]
        } ON COLUMNS
        , NON EMPTY { 
            [Empl].[Name].[Name]
            * [Date].[Calendar].[Month]
        } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
    FROM 
        Cube

) AS t

This works great in SSMS, just like the first query. However this results in the following error in Query-designer:

TITLE: Microsoft Visual Studio
------------------------------

Query preparation failed.

------------------------------
ADDITIONAL INFORMATION:

Please verify that the query is an MDX one and not DMX. (Microsoft.AnalysisServices.Controls)

------------------------------
BUTTONS:

OK
------------------------------

This is the result I'm looking for:

Name     Month     Cost_Type1     Cost_Type2     Cost_Type3
a        january   1.54           1.56           2.43
a        january   3.53           2.34           1.23
b        january   3.53           2.13           4.53

How can I get this query working in the Query-designer (from BIDS, Visual Studio)?

Was it helpful?

Solution

Since you want the [Measures].[Amount] measure repeated on columns for each [Cost Type], you have no other option than creating calculated members for each cost type:

WITH 
MEMBER [Cost_Type1] AS ([Cost Type].[Cost Type].[Cost_Type1], [Measures].[Amount])
MEMBER [Cost_Type2] AS ([Cost Type].[Cost Type].[Cost_Type2], [Measures].[Amount])
MEMBER [Cost_Type3] AS ([Cost Type].[Cost Type].[Cost_Type3], [Measures].[Amount])

SELECT { [Cost_Type1], [Cost_Type2], [Cost_Type3] } ON COLUMNS,
    NON EMPTY { 
        [Empl].[Name].[Name]
        * [Date].[Calendar].[Month]
    } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM 
    Cube

This is due to a limitation in the BIDS query designer - it does not allow for an unknown number of columns at "design-time", thus it is not possible to specify a set on the COLUMNS axis - only single members (even though it works fine in SSMS).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top