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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 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.