Hi @jeanso ,
According to your description, you want to show the last two data in your visual and can be filtered by the date.
Here are the steps you can refer to :
(1)My test data is the same as yours.
(2)We need to create a date table as a slicer like this:
Date = CALENDAR( FIRSTDATE('Table'[Date]) ,LASTDATE('Table'[Date]))
(3)Then we need to create a measure:
Measure = var _min_slicer_date = MIN('Date'[Date])
var _max_slicer_date = MAX('Date'[Date])
var _code = MAX('Table'[Part code])
var _cur_date = MAX('Table'[Date])
var _t = FILTER( ALLSELECTED('Table') , 'Table'[Date] >= _min_slicer_date && 'Table'[Date] <= _max_slicer_date && 'Table'[Part code] = _code )
var _t2 = SELECTCOLUMNS(TOPN(2,_t , [Date] ,DESC),"date" , [Date])
IF(_cur_date in _t2 ,1,-1)
(4)Then we can put the measure on the "Filter on this visual" and put the fields on the visual and we can meet your need:
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.