MDX Help needed

  • I am writing one MDX query like

    select

    {[Measures].[Value]} ON COLUMNS,

    {[X].[X Name].[My Name]}*

    {[Y].[Y Name].[ALL].CHILDREN}*

    {[Date].[Gregorian Date].[ALL].CHILDREN} on rows

    from MyCube

    I have result like

    My Name Y Name Date1 Value1

    My Name Y Name Date2 Value2

    I need the records for max date. means i need to get 2nd row from above result. How do i get this in MDX.

    Thanks In Advance,

    Amol.

  • You haven't really given enough information for us to help you. Do you want the max date for the entire cube, for "Y Name", or for the "My Name, Y Name" combination?

    The Tail() function will give you the max date for the set specified, but we don't know what set you need to specify. You may need to use the Generate() function and/or the Filter() function to specify the set.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Thanks for quick reply.

    Actually i need last record for X and Y combination.

    Hope you get my question.

    Thanks,

    Amol.

  • Without access to your cube, it's really hard to come up with the exact syntax, but you're going to need something like the following

    Generate(

    ( x.CurrentMember, y.CurrentMember )

    , Tail( Filter( [Date].[Gregorian Date].Children, [Measures].[Value] ) )

    )

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Thanks much.

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

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