Search code examples
azurepowerbiazure-stream-analytics

Show current (latest) value from Azure stream in Power BI


I need to display current (last reading) from a connected temperature sensor. Data from the sensor is sent to Azure IoT Hub once every minute. Stream Analytics job outputs it into Power BI sink. This is JSON data the sensor sends: { "temp": "22.88", "name": "POC", "id": "232053ab5ba5ceee", "time": "2018-09-23 07:09:06", "agentid": "ZRQOfcbeFBHk" }
That's what PowerBI receives: [ { "temp": "AAAAA555555", "name": "AAAAA555555", "id": "AAAAA555555", "time": "AAAAA555555", "agentid": "AAAAA555555", "EventProcessedUtcTime": "2018-09-23T07:22:56.643Z", "PartitionId": 98.6, "EventEnqueuedUtcTime": "2018-09-23T07:22:56.643Z", "IoTHub": "AAAAA555555" } ]

What is PartitionId and how do I display just the latest reading (current temperature) only? PowerBI


Solution

  • What is PartitionId?

    Based on your description, your data source is IOT-HUB, so it's the partitionId of IOT-HUB service.You could refer to this case to learn about it: Sending message to Azure IoT hub partition

    Here is a excellent blog for your reference, especially the "Power BI Real-time Dashboard" chapter.

    Open the data set and you’ll see the table under data set with two fields we’ve passed (ts, and value) plus other fields from Event Hub (EventEnqueuedUtcTime, EventProcessedUtcTime, and PartitionId).

    how do I display just the latest reading (current temperature) only?

    As I know, you could implement it on the desktop via measure.

    result = 
    VAR maxdate =
        CALCULATE ( MAX ( Table1[time] ), ALL ( Table1 ) )
    RETURN
      CALCULATE(MAX(Table1[temp]),FILTER(Table1,Table1[time]=maxdate)) 
    

    and

    result = 
    VAR maxdate =
        CALCULATE ( MAX ( Table1[time] ), ALL ( Table1 ) )
    RETURN
        IF ( MAX(Table1[time]) = maxdate, MAX(Table1[temp]), BLANK () )  
    

    respectively corresponding to two below display ways.

    enter image description here