ssasmdxmdx-query

How to use OR in MDX


I want to return Total Sales for 2019 for County = X OR City = Y. How can I do that?

This returns error:

SELECT
{[Measures].[Total Sales]} ON 0,
{[Date].[Date].[Year].&[2019]} ON 1
FROM [Cube]
WHERE 
{([County].[County].[X]),([City].[City].[Y])}

Two sets specified in the function have different dimensionality.


Solution

  • You need to address the hierarchility and dimensionality of the sets. Use the sample below.

    SELECT
    {[Measures].[Total Sales]} ON 0,
    {[Date].[Date].[Year].&[2019]} ON 1
    FROM [Cube]
    WHERE 
    {
    ([County].[County].[X],[City].[City].defaultmember),
    ([County].[County].defaultmember,[City].[City].[Y])
    }