cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Problem with service QueryNamedPropertyHistory

ad'orso-2
1-Visitor

Problem with service QueryNamedPropertyHistory

Hello to all

I have a problem extracting data with the QueryNamedPropertyHistory service

Following is the example

I have a thing with the properties flow1 and flow2

If I extract data from the only property flow1 here is the result


If I extract data from the only property flow2 here is the result

If I pull both properties together here is the result

Why are the values duplicated?

How can I properly extract the values of both properties together?

Thanks in advance

Antonio

ACCEPTED SOLUTION

Accepted Solutions

Hi Antonio,

What QueryNamedPropertyHistory does it's merge both ValueStreams, and as you can note on your data the milliseconds for entries are different, then instead of creating empty values what QueryNamedPropertyHistory does it's fill with previous value when there's no value for the given timestamp.

Data on ValueStreams are stored by property, it's not a Table with a column for each property.

If you want a row for each exact timestamp then you may query one property by one ( as your first two examples ) and then Pivot both infotables with Pivot snippet.

Best Regards,

Carles.

View solution in original post

8 REPLIES 8

Hi Antonio,

What QueryNamedPropertyHistory does it's merge both ValueStreams, and as you can note on your data the milliseconds for entries are different, then instead of creating empty values what QueryNamedPropertyHistory does it's fill with previous value when there's no value for the given timestamp.

Data on ValueStreams are stored by property, it's not a Table with a column for each property.

If you want a row for each exact timestamp then you may query one property by one ( as your first two examples ) and then Pivot both infotables with Pivot snippet.

Best Regards,

Carles.

OK thanks Carles.

so the only way to have both properties is to run the QueryNamedPropertyHistory service for each property and put the results into a correct infotable?

Best Regards

Antonio

Well to just query one by one, maybe better if you use "QueryNumberPropertyHistory" service instead of QueryNamedPropertyHistory, the second one it's more meant to query multiple properties in once.

sorry

but how do I define the query to go to the service?

what type of use?

  var query =

{

    "filters": {

        "type": ????,

        "fieldName": "Flow1,Flow2"

    }

};

var params = {

oldestFirst: undefined /* BOOLEAN */,

maxItems: undefined /* NUMBER */,

propertyName: undefined /* STRING */,

endDate: data2 /* DATETIME */,

query: query /* QUERY */,

startDate: data1 /* DATETIME */

};

// result: INFOTABLE dataShape: "NumberValueStream"

var result = me.QueryNumberPropertyHistory(params);

If you don't need to query data, just keep it undefined.

I do not understand how to get the value of multiple properties together (flow1 and flow2) with the QueryNumberPropertyHistory service.

can you please make an example for me?

No you can't query more than one property at once with QueryNumberPropertyHistory, what I've meant it was that if you need to query one by one property instead of using QueryNamedPropertyHistory it's better to use QueryNumberPropertyHistory.

ok now it's all clear to me

thanks for everything

Best Regards

Antonio

Announcements


Top Tags