Forum Discussion
Brighton10
5 years agoHelper II
Return value based on latest date
Hello, I have a table that has the following columns (attached) and i would like to calculate/return only the latest status, in this example 37. This is just a subset of the entire dataset which ...
- 5 years ago
Hi Brighton10 ,
You can use a dax as follows:
StatusInLast24Hours =
var t1 = SELECTEDVALUES(tablename[datetime])var t2 = t1 - 1
RETURN
CALCULATE(MAX(tablename[status]), tablename[dateTime] <= t1 && tablename[dateTime] > t2)
Thanks,
Pragati
Brighton10
5 years agoHelper II
Thanks Pragati11 , Your solution works perfectly. Just a follow up question. If i want the datetime to filter from the previous 24hrs. How can i implement that?
Pragati11
5 years agoSuper User
Hi Brighton10 ,
You can use a dax as follows:
StatusInLast24Hours =
var t1 = SELECTEDVALUES(tablename[datetime])
var t2 = t1 - 1
RETURN
CALCULATE(MAX(tablename[status]), tablename[dateTime] <= t1 && tablename[dateTime] > t2)
Thanks,
Pragati