Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
I have 2 infotables with same datashape. I need to compare them and store the difference in third infotable.
For example,
DifferenceTable.Reading = CurrentTable.Reading - PreviousTable.Reading
where Reading is a property name for all 3 tables.
Kindly provide solution for same.
Regards,
Siddharth
Solved! Go to Solution.
The easiest way to do this is to just iterate through the infotables and compare the columns one-by-one and then store the differences in a third infotable.
For example, if you know that the rows in the first two tables should be directly compared (i.e. you want to compare row 1 of the first table with row 2 of the second table:
var len = myInfoTable1.getRowCount()
var params = {
infoTableName : "InfoTable",
dataShapeName : "MyDataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(EAS.Mun.DataShape.ContactImport)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
for(var i = 0; i < len; i++) {
var diff1 = myInfoTable2[i].Reading - myInfoTable1[i].Reading;
var diff2 = myInfoTable2[i].AnotherReading - myInfoTable1[i].AnotherReading;
var row = new Object();
row.Reading = diff1;
row.AnotherReading = diff2;
result.AddRow(row);
}
The easiest way to do this is to just iterate through the infotables and compare the columns one-by-one and then store the differences in a third infotable.
For example, if you know that the rows in the first two tables should be directly compared (i.e. you want to compare row 1 of the first table with row 2 of the second table:
var len = myInfoTable1.getRowCount()
var params = {
infoTableName : "InfoTable",
dataShapeName : "MyDataShape"
};
// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE(EAS.Mun.DataShape.ContactImport)
var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);
for(var i = 0; i < len; i++) {
var diff1 = myInfoTable2[i].Reading - myInfoTable1[i].Reading;
var diff2 = myInfoTable2[i].AnotherReading - myInfoTable1[i].AnotherReading;
var row = new Object();
row.Reading = diff1;
row.AnotherReading = diff2;
result.AddRow(row);
}