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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

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

mberber
11-Garnet

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.

1 ACCEPTED SOLUTION

Accepted Solutions
posipova
20-Turquoise
(To:mberber)

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
posipova
20-Turquoise
(To:mberber)

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?

Top Tags