Forum Discussion
Anonymous
4 years agoNot applicable
Previous row value
Hi there,
I need to get previous row value (OFFER_TYPE) and need help. I tried DAX but its only giving me partial result.
The resulted values should be previous rows taken from column "OFFER_TYPE", as marked in blue in column "previous value".
| INDEX | POD_PDR CODE | DATE | OFFER_TYPE | PREEVIOUS VALUE |
1 | 16666 | 01/01/21 | NEG | |
| 2 | 16666 | 01/02/21 | NEG | NEG |
| 3 | 16666 | 01/03/21 | SEMINEG | NEG |
| 4 | 16666 | 01/04/21 | SEMINEG | SEMINEG |
| 5 | 16666 | 01/05/21 | SEMINEG | SEMINEG |
My DAX formula:
_getResult =
var _currentIndex=MAX(cb_attiva[INDEX])
var off_ = cb_attiva[OFFER_TYPE]
var final = CALCULATE( off_, FILTER(ALL(cb_attiva),cb_attiva[Indice]=_currentIndex-1))
return
final
I will appreciate your help.
- Anonymous4 years ago
Hi Anonymous ,
Please try add a new column by below dax formula:
Pre_Offer_type = VAR cur_index = 'Table'[INDEX] VAR pre_index = cur_index - 1 VAR pre_value = CALCULATE ( MAX ( 'Table'[OFFER_TYPE] ), FILTER ( 'Table', 'Table'[INDEX] = pre_index ) ) RETURN pre_valueBest regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1 Reply
- AnonymousNot applicable
Hi Anonymous ,
Please try add a new column by below dax formula:
Pre_Offer_type = VAR cur_index = 'Table'[INDEX] VAR pre_index = cur_index - 1 VAR pre_value = CALCULATE ( MAX ( 'Table'[OFFER_TYPE] ), FILTER ( 'Table', 'Table'[INDEX] = pre_index ) ) RETURN pre_valueBest regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.