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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register 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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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