Case Statement for SSAS Dimension's using mdx

  • Hi Guys,

    I have designed a cube, Now I want to filter Dimension's data using Case statement. Here is the query written but i am getting an error

    "The following syntax error occurred during parsing: Invalid token"

    Query:

    With Member [Measures].

    As

    Case [OMS Order 1].[Movement Type].[Movement Type].CurrentMember

    When [OMS Order 1].[Movement Type].&[PORT TO FTWZ] Then "Import"

    When [OMS Order 1].[Movement Type].&[FTWZ TO DTA] Then "Import"

    When [OMS Order 1].[Movement Type].&[DTA TO FTWZ] Then 'Export"

    When [OMS Order 1].[Movement Type].&[FTWZ TO PORT] Then "Export"

    Else "Null"

    End

    Select {[Measures].,[Measures].[Order Progress Dashboard Count]} on Columns,

    {[OMS Order 1].[Office].Members} on rows

    from Cube

    I am not getting what went wrong

    Thanks.....

  • Hi Blushan,

    can you try the MDX without the slash? Possibly being interpretted as an escape character.

    e.g.

    With Member [Measures].[IE]

    As

    Case [OMS Order 1].[Movement Type].[Movement Type].CurrentMember

    When [OMS Order 1].[Movement Type].&[PORT TO FTWZ] Then "Import"

    When [OMS Order 1].[Movement Type].&[FTWZ TO DTA] Then "Import"

    When [OMS Order 1].[Movement Type].&[DTA TO FTWZ] Then 'Export"

    When [OMS Order 1].[Movement Type].&[FTWZ TO PORT] Then "Export"

    Else "Null"

    End

    Select {[Measures].[IE],[Measures].[Order Progress Dashboard Count]} on Columns,

    {[OMS Order 1].[Office].Members} on rows

    from Cube

    Steve.

  • i have tried both query but nothing comes up...

  • In the third "When .. " row, you have a ' instead of " .

    Franky Leeuwerck

    Franky L.

  • this should work

    with member [Measures].[x] as

    case [Measures].[measuregroup]

    when [Date].[Date Id].&[20110101] then '[Measures].[x]'

    else '0'

    end

    Select [Company].[Company] on 0,

    [Date].[Date Id] on 1

    from [cube]

    where [Measures].[x]

    try defaulting to different number other then null

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply