March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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 consists of different countries and items. I have tried using the lastdate, max functions but I cant seem to work out the logic.
Thanks for your help!
Solved! Go to Solution.
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
Try the below Measure by considering Datetime Column has a proper datetime format.
Hi @Brighton10 ,
You can write the following DAX measure:
RecentStatus =
var t1 = MAX(tablename[dateTime])
RETURN
CALCULATE(MAX(tablename[status]), tablename[dateTime] = t1)
thanks,
Pragati
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?
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 , Try a measure like
lastnonblankvalue(Table[datetime], max(Table[Status]))
calculate(lastnonblankvalue(Table[datetime], max(Table[Status])), all(Table))
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |