Forum Discussion
gchn
3 years agoFrequent Visitor
Measure to get previous value with same attributes
I have a table with multiple attribute/category columns (call them A1, A2, ...), a date column and a value column. I've been trying for too long to get a measure that gives me the value for the prev...
grazitti_sapna
3 years agoSuper User
Hi gchn
Try using:-
new_measure =
VAR CurrentDate = MAX('YourTable'[date])
VAR PrevDate =
CALCULATE(
MAX('YourTable'[date]),
FILTER(
ALL('YourTable'),
'YourTable'[date] < CurrentDate &&
'YourTable'[A1] = EARLIER('YourTable'[A1]) &&
'YourTable'[A2] = EARLIER('YourTable'[A2]) &&
...
)
)
RETURN
IF(ISBLANK(PrevDate), BLANK(),
CALCULATE(
MAX('YourTable'[value]),
FILTER(
ALL('YourTable'),
'YourTable'[date] = PrevDate &&
'YourTable'[A1] = EARLIER('YourTable'[A1]) &&
'YourTable'[A2] = EARLIER('YourTable'[A2]) &&
...
)
)
)
Hope this will help.