Forum Discussion
nbufff
Helper I
1 year agoGet 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?
Thanks for help!
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))RETURNIF(ISBLANK(PreviousQty),0,PreviousQty)if it's ok, please accept my answer as solution!
BBF
2 Replies
- BeaBF
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))RETURNIF(ISBLANK(PreviousQty),0,PreviousQty)if it's ok, please accept my answer as solution!
BBF