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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
sathishsam
Helper II
Helper II

I am not able to get the Value from a column based on maximum date from another column

Hi Experts,

 

Here is my simple model. I am trying to get the Latest Temperature from the below table (This is a live stream data)

 

Latest Temp =
var dt = CALCULATE(LASTDATE(RealTimeData[Date]), ALLSELECTED(RealTimeData))
RETURN
CALCULATE(SUM(RealTimeData[Temperature]), RealTimeData[Date] = dt)

sathishsam_0-1732252196658.png

Not sure why Latest Temp returns blank 😞

1 ACCEPTED SOLUTION
sathishsam
Helper II
Helper II

I solved it by adding a DateKey column

DateKey = YEAR(RealTimeData[Date])&Month(RealTimeData[Date])&Day(RealTimeData[Date])

Latest Temp =
Var Result= CALCULATE(SUM(RealTimeData[Temperature]),
    RealTimeData[DateKey] = MAX(RealTimeData[DateKey]))
RETURN
Result

View solution in original post

10 REPLIES 10
sathishsam
Helper II
Helper II

I solved it by adding a DateKey column

DateKey = YEAR(RealTimeData[Date])&Month(RealTimeData[Date])&Day(RealTimeData[Date])

Latest Temp =
Var Result= CALCULATE(SUM(RealTimeData[Temperature]),
    RealTimeData[DateKey] = MAX(RealTimeData[DateKey]))
RETURN
Result
Uzi2019
Super User
Super User

Hi @sathishsam 
Try this 

 

Measure= 
Var Max_date= Max( 'Table'[Date])
Var Result= Calculate ( Sum( 'RealTimeData'[Temperature]), Filter ( ALL(RealTimeData), [Date]= Max_date))

 

I hope this may resolve your query.

 

I hope I answered your question!

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

It didn't work

Rupak_bi
Super User
Super User

Hi @sathishsam 

Your date have timestamp as well. Instead of LASTDATE, Try using MAX(table,date). This should work.



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/

MAX didn't work

Hi @sathishsam ,

Please ensure there is no other filter or slicer in the dashboard. Max should work.
alternate way....

I also can see, you already have a measure "maxDt". you can refer that as well.

Latest Temp =calculate(SUM(RealTimeData[Temperature]),allexcept(RealTimeData,RealTimeData[City]), RealTimeData[Date] =[maxDt])



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/
Mahesh0016
Super User
Super User

@sathishsam please try the below DAX.

 

Latest Temp =
VAR dt = CALCULATE(
                                        MAX( RealTimeData[Date] )
                                      , ALLSELECTED(  RealTimeData[City], RealTimeData[Date]  )
                            )

VAR  Temperatures = SUM(RealTimeData[Temperature])

RETURN
CALCULATE(
                      Temperatures
                      , RealTimeData[Date] = dt
                 )

@sathishsam i hope this helps you. Thank You!

Thanks Mahesh, this is returning me 226.20 (Total Temperature). I am expecting 22.8

@Rupak_bi 
ohk, do you want to city wise latest Temperature...?

please brief me on it. Thank You!

yes, at present i have data only for one city (Bangalore)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors