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

How to compare two InfoTable or DataTable Values and find missing value?

SOLVED
Highlighted
Contributor

How to compare two InfoTable or DataTable Values and find missing value?

Hello Everyone ;

In our project there are two DataTable. Both have services which output as InfoTable. We can call them testData and raspiData. Normally this two table must be have equal data. But when it doesnt i want to know which row is missing.

testData                                                                                                                                                                                                       raspiData

result data

My service wont work properly. I dont know where i wrong. It should be list only Barcode "1005" because it isnt in the other table.

var testData = Things["testDT"].Select();

var raspiData = Things["RaspiData"].Select();

//-----------------------------------------------------------

var params = {

infoTableName : "InfoTable",

dataShapeName : "testDS"

};

var result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape(params);

//--------------------------------------------------

var tableLength = testData.rows.length;

for (var x = 0; x < tableLength; x++) {

var row = testData.rows;

        var tableLength2 = raspiData.rows.length;

            for (var y = 0; y < tableLength2; y++) {

                var row2 = raspiData.rows;

   if(row.Barcode != row2.Barcode){           

             

var newEntry = new Object();

             

                newEntry.Barcode   = row.Barcode;

                newEntry.ProdID    = row.ProdID;

                newEntry.StationID = row.StationID;

     result.AddRow(newEntry);    

   }

   }        

}

Any help will be appreciated.

Thank you.

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to compare two InfoTable or DataTable Values and find missing value?

You could try comparing the number of entries in each and then for the one that has more entries, query each for the other table until you hit a missing one, then add?

View solution in original post

1 REPLY 1

Re: How to compare two InfoTable or DataTable Values and find missing value?

You could try comparing the number of entries in each and then for the one that has more entries, query each for the other table until you hit a missing one, then add?

View solution in original post

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________