Forum Discussion
MASF
3 years agoFrequent Visitor
Most recent MAX value
Hello Anybody knows how to create a DAX measure to get the LATEST (most recent) MAX value? For example, in the set of dates bellow, the most recent max value is 115 and it happened on the 2022-1...
- 3 years ago
hi MASF
Now i see, try to write a measure like this:
LastestPeak = VAR _table = FILTER( TableName, VAR _val = [val] VAR _date = [date] VAR _valpre = MINX( FILTER( TableName, _date -1 = [date] ), [val] ) RETURN IF(_val>_valpre, TRUE, FALSE) ) VAR _datemax = MAXX(_table, TableName[date]) RETURN MAXX( FILTER( _table, TableName[date]=_datemax ), TableName[val] )
FreemanZ
3 years agoSuper User
hi MASF
are you expecting two measures like this:
MaxValue = CALCULATE(MAX(TableName[val]), ALL(TableName))
MaxValueDate =
VAR _MaxValue = [MaxValue]
RETURN
MAXX(
FILTER(
TableName,
TableName[val] = MaxValue
),
TableName[date]
)- MASF3 years agoFrequent Visitor
Hi FreemanZ
Thank you for your time.
That would give the max value in all dataset, it's not what I need.
As mentioned, I am looking for the latest max value, before the value drops again.
Considering the example I gave, the value I am looking is 115 - your measure gives the max in the dataset, 120. 115 is the latest max value in the date range give, since on the previous day (2022-10-08) the value drops to 110.
Thanks, Miguel
- FreemanZ3 years agoSuper User
hi MASF
Now i see, try to write a measure like this:
LastestPeak = VAR _table = FILTER( TableName, VAR _val = [val] VAR _date = [date] VAR _valpre = MINX( FILTER( TableName, _date -1 = [date] ), [val] ) RETURN IF(_val>_valpre, TRUE, FALSE) ) VAR _datemax = MAXX(_table, TableName[date]) RETURN MAXX( FILTER( _table, TableName[date]=_datemax ), TableName[val] )