Forum Discussion
tlong
6 years agoRegular Visitor
Find previous date for given value
Hi, I'm trying to create a calculated column that will show the latest previous date for an associated value. In the example below, I have the "Date" and "Value" columns, and I'm trying to gener...
- 6 years ago
Hey tlong
use this DAX statement to create a calculated column:
Column = var _group = 'Table'[Value] var _date = 'Table'[Date] return CALCULATE( MAX('Table'[Date]) , FILTER( ALL('Table') , 'Table'[Date] < _date && 'Table'[Value] = _group ) )The result will look like this:
Please be aware that depending of number of rows in your dataset can become incredibly slow, this is simply because the formula and storage engine do not support windowing operations like this.Hopefully this is what you are looking for.
Regards,
Tom
Ashish_Mathur
6 years agoSuper User
Hi,
This calculated column formula should work
=CALCULATE(MAX(Data[Date]),FILTER(Data,Date<EARLIER(Data[Date])))
Hope this helps.