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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.