Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
Hi,
I have logged property into a value stream and using QueryPropertyHistory service I am able to have a view at the recorded data of the logged properties. What next I wan to achieve is how can we calculate the number of times a value of a property repeats in the data recorded, upto a particular date.
eg, I have property called stepValueStatus which has a string value pass/fail. So I want to calculate how many times pass occurs and how many times fail occurs for this stepValueStatus property.
Thanks in Advance.
Regards,
Aditya Gupta
Solved! Go to Solution.
Hi @Aditya1702
Set your service Output as InfoTable and set DataShape to it.
In Mashup, Call this service and map output to Grid Widget.
/VR
Hi @Aditya1702
You can use the Aggregate Function to get a count of values
let params = {
t: me.dummyInfoTable/* INFOTABLE */,
columns: "name" /* STRING */,
aggregates: "COUNT" /* STRING */,
groupByColumns: "name" /* STRING */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Aggregate(params);
Input:
Output :
/VR
Hi @Velkumar ,
What to add in place of dummyInfotable since I don't have any infotable I get infotable as an output of QueryPropertyHistory Service.
Can you please elaborate a bit more since, I am new to ThingWorx.
Thanks in Advance.
Regards,
Aditya Gupta
Hi @Aditya1702
Replace me.dummyInfoTable with an output of QueryPropertyHistory service
var data = me.QueryPropertyHistory({
maxItems: undefined /* NUMBER {"defaultValue":500} */,
startDate: undefined /* DATETIME */,
endDate: undefined /* DATETIME */,
oldestFirst: undefined /* BOOLEAN */,
fillOption: undefined /* STRING {"defaultValue":"Previous"} */,
query: undefined /* QUERY */
});
let params = {
t: data /* INFOTABLE */,
columns: "FIELDNAME_TO_COUNT" /* STRING */,
aggregates: "COUNT" /* STRING */,
groupByColumns: "FIELDNAME_TO_COUNT" /* STRING */
};
// result: INFOTABLE
let result = Resources["InfoTableFunctions"].Aggregate(params);
/VR
Hi @Velkumar ,
Thank you it did worked!!!
One more thing what if I want to display these counts (T1 as 3, T2 as 2 & T3 as 1) in mashup how can I go about this?
Hi @Aditya1702
Set your service Output as InfoTable and set DataShape to it.
In Mashup, Call this service and map output to Grid Widget.
/VR
Hi @Velkumar ,
Good Evening,
I am facing problem in logging properties there are some values which are repeating after I carry out the experience third time.
PFA attached image in which arrows are shown on the readings which are repeating when I consume the AR experience on my Ipad on view app the third time.
Thanks in Advance.
Hello,
The repetition of the values is random.
Can anyone help me out with this?
Thanks in Advance.