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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

QueryPropertyHistory Strange Behavior (Return no rows)

AliBenBelgacem
14-Alexandrite

QueryPropertyHistory Strange Behavior (Return no rows)

Hello,

I have a strange behavior of QueryPropertyHistory when i try to test it on thingworx services. Im a newbies so i may miss some core functionality of this function.

 

Here is my code:

var query = {
filters: {
type: "LIKE",
fieldName: "MSN",
value: MSN
}
};
// result: INFOTABLE dataShape: ""
var result = me.QueryPropertyHistory({
oldestFirst: OldestFirst /* BOOLEAN */,
maxItems: MaxItems /* NUMBER */,
endDate: EndDate /* DATETIME */,
query: query /* QUERY */,
startDate: StartDate /* DATETIME */
});

 

I try to fetch properties values from the thing used en second time to generate statistics:

 

the thing store data on valustream database.

Scenario:

1- I run this test (1.JPG)

 1.JPG

As you can see there is rows returned ans there is data on the date 10/30/2019 : 5:30 pm.

 

2-Now let's do the same test but we change the start date to the current day

Result : (No data)

2.JPG

The first screenshot show that i have data in this date but when i filter the date i got no rows!

 

I have no explanation for this ?

 

Can you help me  please.

 

Many thanks.

 

 
1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

 

I'm not sure what exactly happens inside your QueryPropertiesHistory, so I can only guess that this information will be useful to understand the source of your problem:

 

QueryPropertyHistory extrapolates data points. So if you have 2 subsequent changes like this:

 

thing.property1 = 'first';  // At 08:00

thing.property2 = 'second'; // At 08:10

 

Then when querying for all properties it will take all timestamps and interpolate the values as if they were set at that moment (it will use the last known value):

 

Timestamp property1 property2
08:00 first ?
08:10 first second

 

All this interpolation happens inside the Query service, in the database it only stores two events. It's easy to see if you query it via QueryNumericPropertyHistory, which doesn't interpolate values and return them as in the database.

 

I hope it helps. Otherwise provide the code for this QueryPropertiesHistory, so that we can take a look.

 

/ Constantine

View solution in original post

2 REPLIES 2

Hello,

 

I'm not sure what exactly happens inside your QueryPropertiesHistory, so I can only guess that this information will be useful to understand the source of your problem:

 

QueryPropertyHistory extrapolates data points. So if you have 2 subsequent changes like this:

 

thing.property1 = 'first';  // At 08:00

thing.property2 = 'second'; // At 08:10

 

Then when querying for all properties it will take all timestamps and interpolate the values as if they were set at that moment (it will use the last known value):

 

Timestamp property1 property2
08:00 first ?
08:10 first second

 

All this interpolation happens inside the Query service, in the database it only stores two events. It's easy to see if you query it via QueryNumericPropertyHistory, which doesn't interpolate values and return them as in the database.

 

I hope it helps. Otherwise provide the code for this QueryPropertiesHistory, so that we can take a look.

 

/ Constantine

I agree with @Constantine analysis.

Probably there was no value logged between 12:00 am and 5:30 pm on 30-Oct.

The values shown on 1.JPG during this period are probably interpolated - you can validate using the Query<BASETYPE>PropertyHistory service -  this service does not perform interpolation and returns logged value only.

Top Tags