Thursday, 29 December 2016

MDX -- PREVMEMBER and NEXTMEMBER Functions -- Part-14

                    MDX -- PREVMEMBER and NEXTMEMBER  Functions -- Part-14
PREVMEMBER Function :-                                                                                                                           
                                                                                                The PREVMEMBER Function Returns the Previous member in the level that contains a specified member.

-- Actual MDX Query
SELECT [Measures].[Order Quantity] ON COLUMNS
      ,[Order Date].[Date Hierarchy].[Year]
        ON ROWS
FROM MSBI



  
-- 1. PREVMEMBER
-- Example -1
SELECT [Measures].[Order Quantity] ON COLUMNS
      ,[Order Date].[Date Hierarchy].[Year].&[CY 2008].&[CY 2008 SEM 2].&[2008 Q3]
     .&[July 2008].PREVMEMBER
        ON ROWS
FROM MSBI



-- Example -2
SELECT [Measures].[Order Quantity] ON COLUMNS
      ,[Order Date].[Date Hierarchy].[Year].&[CY 2008].PREVMEMBER
        ON ROWS
FROM MSBI



-- Example -3
SELECT [Measures].[Order Quantity] ON COLUMNS
      ,[Order Date].[Date Hierarchy].[Year].&[CY 2008].PREVMEMBER.PREVMEMBER
        ON ROWS
FROM MSBI


NEXTMEMBER Function :-                                                                                                                           
                                                              The NEXTMEMBER Function Returns the Next member in the level that contains a specified member.


-- Example -1
SELECT [Measures].[Order Quantity] ON COLUMNS
      ,[Order Date].[Date Hierarchy].[Year].&[CY 2008].NEXTMEMBER
       ON ROWS
FROM MSBI



-- Example -2
SELECT [Measures].[Order Quantity] ON COLUMNS
     ,[Order Date].[Date Hierarchy].[Year].&[CY 2009].NEXTMEMBER.NEXTMEMBER
        ON ROWS
FROM MSBI



-- Combination of PREVMEMBER and NEXTMEMBER
-- Example -3
SELECT [Measures].[Order Quantity] ON COLUMNS
     ,[Order Date].[Date Hierarchy].[Year].&[CY 2009].NEXTMEMBER.PREVMEMBER
        ON ROWS

FROM MSBI






Thanks for Looking into this.....




No comments:

Post a Comment