I'm using the last function to create a flag that identifies the latest record received (so I can dashboard only the latest values in Power BI).
SELECT
events.deviceId
,events.[timestamp]
,events.externaltemp
,LAST(events.[timestamp]) OVER (PARTITION BY events.DeviceId LIMIT DURATION(day, 1) ) as latest
,case when LAST(events.[timestamp]) OVER (PARTITION BY events.DeviceId LIMIT DURATION(day, 1) ) = [timestamp] then 1 else 0 end as LastestFlag
INTO
[powerBI]
FROM
[EventHub] as events timestamp by [timestamp]
However I am seeing that the last function is always returning the same datetime as my timestamp, so all rows in my query look like they are the last one that was received. My data has a record for every second.
(alternatively, I was hoping to use the row_number function to give me something to filter on to identify the latest record - but this doesn't appear to exist in stream analytics yet)