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
nbufff
Helper I
Helper I

Get value from previous row by DAX

Hello, I stuck in the DAX formual by tring to get value from previous row.

 

With Below example, when Date and SKU are same:

D3=D2

D4=D3

D6=D5

....

How can we achieve that by adding Column D (Qty2) in using DAX?

nbufff_0-1729666848533.png

 

 

Thanks for help!

1 ACCEPTED SOLUTION
BeaBF
Super User
Super User

@nbufff Hi! Create a new calculated column with this code:

Qty2_col =
VAR CurrentDate = 'Table'[Date]
VAR CurrentSKU = 'Table'[SKU]
VAR CurrentQty1 = 'Table'[Qty1]

VAR PreviousQty =
    CALCULATE(
        MIN('Table'[Qty1]),
        FILTER(
            'Table',
            'Table'[Date] = CurrentDate &&
            'Table'[SKU] = CurrentSKU &&
            'Table'[Qty1] > CurrentQty1
        )
    )

RETURN
IF(
    ISBLANK(PreviousQty),
    0,
    PreviousQty
)
BeaBF_0-1729670663867.png

 

if it's ok, please accept my answer as solution!

 

BBF

View solution in original post

2 REPLIES 2
nbufff
Helper I
Helper I

@BeaBF THANKS for help, it's working on my side!

BeaBF
Super User
Super User

@nbufff Hi! Create a new calculated column with this code:

Qty2_col =
VAR CurrentDate = 'Table'[Date]
VAR CurrentSKU = 'Table'[SKU]
VAR CurrentQty1 = 'Table'[Qty1]

VAR PreviousQty =
    CALCULATE(
        MIN('Table'[Qty1]),
        FILTER(
            'Table',
            'Table'[Date] = CurrentDate &&
            'Table'[SKU] = CurrentSKU &&
            'Table'[Qty1] > CurrentQty1
        )
    )

RETURN
IF(
    ISBLANK(PreviousQty),
    0,
    PreviousQty
)
BeaBF_0-1729670663867.png

 

if it's ok, please accept my answer as solution!

 

BBF

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.