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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

find uncommon records in infotables without for loop.

AP_10343008
14-Alexandrite

find uncommon records in infotables without for loop.

I have infotable A and infotable B.

Ill compare data in both infotable A and infotable B.

Ill delete the matched records in both tables and the uncommon records remains in both the tables infotable A and infotable B.

How it can be done without using for loop?

Any infotable functions will be helpful?

 

 

1 REPLY 1

Even if you wouldn't use a for loop, one would have to be used internally, so it doesn't make a difference. You can't do this without iterating the values.

TBH instead of altering the infotables I would just create new ones. This is how you could compute A minus B, assuming you compare on column age.

If you need to compare every property, it's more complex.

 

let result = Resources["InfoTableFunctions"].CreateInfoTable();
result.AddField({name:"id", baseType:"STRING"});
result.AddField({name:"name", baseType:"STRING"});
result.AddField({name:"age", baseType:"INTEGER"});

let deleteTable = Resources["InfoTableFunctions"].Clone({t1:result});
let resultTable = Resources["InfoTableFunctions"].Clone({t1:result});

result.AddRow({id:"4",name:"A",age:10});
result.AddRow({id:"5",name:"B",age:20});
result.AddRow({id:"6",name:"C",age:30});
result.AddRow({id:"7",name:"D",age:40});

deleteTable.AddRow({id:"6",name:"C",age:30});
deleteTable.AddRow({id:"7",name:"D",age:40});
deleteTable.AddRow({id:"8",name:"E",age:50});

// until here it's just setting up some data. result would be Table A, deleteTable would be Table B

let delArray=deleteTable.rows.toArray().map(r=>r.id);
result.rows.toArray().forEach(row=>{ if (!delArray.includes(row.id)) resultTable.AddRow(row);});

result=resultTable; // A minus B, now repeat to do B minus A

 

 

Announcements


Top Tags