Tuesday, 19 November 2013

Getting List of Top N Products for each year using MDX


 We can get  List of Top 3Products for each year using MDX by using Generate function along with TOPCOUNT function as shown in the example below.

Example:

SELECT
    {[Measures].[Internet Sales Amount]} ON 0
    ,GENERATE
    (
        [Date].[Calendar Year].[Calendar Year]
        ,TOPCOUNT
        (
            (
                [Date].[Calendar Year].CURRENTMEMBER
                *
                [Product].[Product Categories].[Product].MEMBERS
            )
            ,10
            ,[Measures].[Internet Sales Amount]
            --«Set», «Count»[, «Numeric Expression»]
        )
        --«Set1», «Set2»[, ALL]
    ) ON 1
FROM [Adventure Works]

No comments:

Post a Comment