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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
slendin
New Member

Trying to get latest value per location - measure

I hope you guys can help me with this measure, since iam not a PowerBi god :).

What im trying to do is show the latest temperature by location so i can use the latest temperature value in power bi visuals.

 

Here is an exampe of my sql table: temperature_events

 

timestamp                   temperature          locatie

26-8-2019 12:23:21     19.2                        Hall

26-8-2019 12:21:47     19.9                        Room 1

26-8-2019 12:19:41     20.1                        Hall

26-8-2019 12:16:22     21.1                        Room 2

26-8-2019 12:15:12     19.0                        Room 1

26-8-2019 12:12:10     22.9                        Room 2

 

I tried the following measure, but i get # the expression refers to multible columns. Multible columns cannot be converted to scalar value.

 

CategoriesLatest = SUMMARIZE(temperature_events;temperature_events[locatie];"timestamp";MAX(temperature_events[datetime]);"temperature";CALCULATE(SUM(temperature_events[temperature]);FILTER(temperature_events;temperature_events[datetime]=MAX(temperature_events[timestamp]))))

 

 

1 ACCEPTED SOLUTION
AlB
Super User
Super User

Hi @slendin

You can place Table1[locatie] in the visual and then: 

Measure =
VAR Latest_ =
    CALCULATE ( MAX ( Table1[timestamp] ) )
VAR LatestTemp_ =
    CALCULATE ( DISTINCT ( Table1[temperature] ), Table1[timestamp] = Latest_ )
RETURN
    LatestTemp_

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

View solution in original post

3 REPLIES 3
MatejZukovic
Resolver I
Resolver I

Hi @slendin ,

 

aggregating data in your visual based on last timestamp should do the trick!

 

Capture.JPG

AlB
Super User
Super User

Hi @slendin

You can place Table1[locatie] in the visual and then: 

Measure =
VAR Latest_ =
    CALCULATE ( MAX ( Table1[timestamp] ) )
VAR LatestTemp_ =
    CALCULATE ( DISTINCT ( Table1[temperature] ), Table1[timestamp] = Latest_ )
RETURN
    LatestTemp_

Please mark the question solved when we get to the solution and consider kudoing if posts are helpful.

Cheers  Datanaut

Awesome, worked like a charm! Thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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