SQL OR with MDX

  • I have a Measure called Supplier Number in the cube. The Supplier table acts as a Dimension as well as Fact table in the Cube.

    There are two dimensions - CreationDate and Modification date that are linked to Supplier fact table.

    My requirement is to get the Supplier Number which got Created (CreationDate) or which got modified (Modification date) for any current month selected.

    How to achieve this in MDX?

    Hint: This is like a SQL OR condition with CreationDate and Modification Date.

  • You can put this into the Where condition in a query for a simple solution. For example in AdventureWorks this:

    SELECT

    NON EMPTY [Measures].[Reseller Sales Amount] ON 0,

    [Geography].[State-Province].[State-Province] ON 1

    FROM

    [Adventure Works]

    WHERE

    {[Geography].[Geography].[State-Province].&[NY]&[US],

    [Geography].[Geography].[State-Province].&[SD]&[US]}

    ...would give you reseller sales in New York or South Dakota.


    I'm on LinkedIn

  • If you are pulling the data from a Cube, then MDX. If you are pulling from SQL Database, then SQL.

    If you are going to be working a lot with cubes, I highly recommend learning MDX. It's quite easy to learn, it just messes with your head if you think in SQL terms (two dimensions).

    An awesome book to learn from is: http://www.amazon.com/Practical-MDX-Queries-Microsoft-Analysis/dp/0071713360/ref=sr_1_1?ie=UTF8&qid=1394041795&sr=8-1&keywords=mdx

    I sat down the whole weekend and read through the book, and became pretty good at writing MDX by monday. This book walks you thought examples, which is quite easy to learn from.

    ------------
    🙂

Viewing 3 posts - 1 through 2 (of 2 total)

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