Search code examples
ssasmdx

MDX query quidance


I have an MDX query that needs to display result based on a CASE statement. I have written the below query, the query is not throwing any error neither is it giving out any result.

How can I get the query correct?

Query:

SELECT NULL ON 0,
CASE 
WHEN [MARKET BASE].[Market Base].[Market Base].&[1] = "Vitamin C (04D1+04D2)"
THEN "Vitamin C (04D1 + 04D2)" END ON 1
FROM [PharmaTrend Monthly Ext]
WHERE [PRODUCT].[Company - Product - Pack].[Company].&[2991]

Solution

  • Try this -

    WITH MEMBER Measures.SomeValue AS
        CASE 
        WHEN [MARKET BASE].[Market Base].[Market Base].&[1] IS 
                [MARKET BASE].[Market Base].[Market Base].[Vitamin C (04D1+04D2)]
        THEN "Vitamin C (04D1 + 04D2)" 
        END
    
    
    SELECT 
    Measures.SomeValue ON 0
    FROM [SomeCube]
    WHERE [PRODUCT].[Company - Product - Pack].[Company].&[2991]