Skip to main content
12-Amethyst
September 15, 2017
Solved

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

  • September 15, 2017
  • 1 reply
  • 4032 views

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.

Best answer by posipova

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?

1 reply

posipova20-TurquoiseAnswer
20-Turquoise
September 15, 2017

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?