locked
How to collect data between two time frames RRS feed

  • Question

  • Hi,

    I'm currently exploring the ASA query language and your suggestions on this question will help me in any way.

    We have a streaming input source(IoT hub) with JSON as the input format.

    The incoming data will have a tag and a value. So the condition is that whenever the value changes, the events received between the change of value should be collected as a set.

    Here is the way how I tried:

    I figured out the time difference using LAG & DATEDIFF functions.

    Tried Collect() function. But it collects all the events - could not specify the time frames in the syntax.

    Tried using CASE function, but ended up unsuccessful.

    Also I think there is no way to assign a value and refer it in the query(like we can do in other scripting languages), please correct me if otherwise.

    If you have any suggestions and pointers, let me know so that I can try.

    Thank you very much for your concern on this scenario of mine.

    Friday, January 10, 2020 5:30 AM

All replies

  • Hello Prasanth 

    At this time I will reach out to internal teams for more information.I will update you once I hear from them .


    Thanks Himanshu

    Tuesday, January 14, 2020 12:39 AM
  • Hello 

    Can you please elaborate what do you mean by "the change of value should be collected as a set" please ?

    As I understand at this point you should be able to assign a value to a variable by using the AS clause. 

    For example:
     
    SELECT [column 1] AS time
     

    This can also be done for values computed from functions. Let me know if this helps.

    Just curious if you have two events as 

    {
    tag:"Name",
    value:"Prasanth"
    TIme:"t1"


    }

    {
    tag:"Name",
    value:"HImanshu"
    TIme:"t2"


    }

    What is the output you are expecting ?


    Thanks Himanshu

    Wednesday, January 15, 2020 9:01 PM
  • Thank you Himashu for your response. I'll try the suggestion that you have given.

    Also let me try explaining it here(for clarity). So if we have a data as below

    .
    .
    .
    {
    "tag": "abc",
    "value": 0,
    "time": "2020-01-17T11:30:00.321Z"
    },
    {
    "tag": "abc-phase0",
    "value": 0.5,
    "time": "2020-01-17T11:30:55.021Z"
    },
    {
    "tag": "abc-phase1",
    "value": 12,
    "time": "2020-01-17T11:31:10.381Z"
    },
    {
    "tag": "abc-phase2",
    "value": 34,
    "time": "2020-01-17T11:31:40.321Z"
    },
    {
    "tag": "abc",
    "value": 1,
    "time": "2020-01-17T11:32:00.321Z"
    }
    .
    .
    .

    I'm looking at a tag with the value as 'abc'

    So it first occurred with the value '0' and in the next occurrence, value for the tag 'abc' has changed to '1'

    So whenever this change happens, I need to collect all the data between these two occurrences i.e. the data with the tags value as abc-phase0, abc-phase1, abc-phase2.... all these are to be collected.

    Regards,

    Prasanth E



    • Edited by Prasanth E Monday, January 20, 2020 8:14 AM
    Friday, January 17, 2020 6:16 AM