Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Brighton10
Helper II
Helper 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 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!Demotable.PNG

1 ACCEPTED 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

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

@Brighton10 ,

Try the below Measure by considering Datetime Column has a proper datetime format.

Measure  = CALCULATE(SUM(Sheet10[Status]),FILTER(Sheet10,Sheet10[Date]=MAX(Sheet10[Date])))
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Pragati11
Super User
Super User

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

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

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

 

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Brighton10 , Try a measure like

lastnonblankvalue(Table[datetime], max(Table[Status]))

 

calculate(lastnonblankvalue(Table[datetime], max(Table[Status])), all(Table))

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.