1

I have the following example of JSON which I am trying to send to PowerBI through Azure Stream Analytics.

[{

      "timestamp":1526452793090,
      "values":[
         {
            "id":"Device1.K1001",
            "v":false,
            "q":true,
            "t":1359326344047
         }
      ]
}]

My first assumption was to do the following query:

SELECT 
    timestamp,
    [values].id,
    [values].v,
    [values].q,
    [values].t
INTO
    [PowerBI]
FROM
    [IoTHub]

result in powerBI

Why is the above solution wrong?

Best regards Michael

3
  • It is wrong because values is an array, and you are accessing it like it is a complex type. Commented May 16, 2018 at 8:11
  • @Michael You're welcome ,please mark this answer for others' reference,thx Commented May 24, 2018 at 5:56
  • @Michael You're welcome ,please mark this answer for others' reference,thx Commented Aug 30, 2018 at 5:57

1 Answer 1

3

You could get GetArrayElement ,please refer to my sample query:

WITH 
temp AS
(
SELECT
timestamp ,
GetArrayElement([values],0)as valueObj 
FROM jsoninput 
)

SELECT
    temp.timestamp ,temp.valueObj.id,temp.valueObj.v,temp.valueObj.q,temp.valueObj.t
INTO
    jaycosmostest
FROM
    temp

Output Result:

enter image description here

Hope it helps you.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you very much. That is the solution. I failed to understand the array. Best regards Michael.
@Michael You're welcome ,please mark this answer for others' reference,thx
@Michael You're welcome ,please mark this answer for others' reference,thx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.