Forum Discussion

MWare's avatar
MWare
Icon for Helper I rankHelper I
3 years ago
Solved

DAX Calculation to retrieve the entry before pt2

Hi,   Looking for some help please.   I am trying to return the previous 'Sale Product' based on the 'Sales Person' of each row in my 'Sales' table. Unfortunatley the index is based on all sales...
  • v-jianboli-msft's avatar
    3 years ago

     Hi MWare ,

     

    Please try:

    Column =
    VAR _a =
        MAXX (
            FILTER (
                'Table',
                [Sale Person] = EARLIER ( 'Table'[Sale Person] )
                    && [Shop Sale Index] < EARLIER ( 'Table'[Shop Sale Index] )
            ),
            [Shop Sale Index]
        )
    VAR _b =
        MAXX (
            FILTER (
                'Table',
                [Sale Person] = EARLIER ( 'Table'[Sale Person] )
                    && [Shop Sale Index] = _a
            ),
            [Sale Product]
        )
    RETURN
        _b
    

    Final output:

    Best Regards,

    Jianbo Li

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • MWare's avatar
    MWare
    3 years ago

    Thank you very much this works a treat!