Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MWare
Helper I
Helper I

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 in the shop and thus I can't use -1 on the index as the Sales Person can vary.

See below image in Power BI, the DAX formula I have created using EARLIER in column 'Prior Sales Product (DAX Help)' is not returning the prior sales product for the sales person for the row.  See the 'Prior Sales Product (the answer I'm after)' column for what the value I'm expecting in my DAX formula.

 

Any ideas?

 @wdx223_Daniel2  might be another easy one for you as you managed to solve the previous query

 

MWare_0-1667486718806.png

 

2 ACCEPTED SOLUTIONS
v-jianboli-msft
Community Support
Community Support

 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:

vjianbolimsft_0-1667540970682.png

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.

 

View solution in original post

Thank you very much this works a treat!

View solution in original post

2 REPLIES 2
v-jianboli-msft
Community Support
Community Support

 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:

vjianbolimsft_0-1667540970682.png

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.

 

Thank you very much this works a treat!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.