Farhan Shariff

Farhan Shariff

  • NA
  • 933
  • 242.1k

Compare Datatables - Matching Rows and Columns by Id

May 15 2014 4:49 AM
I am comparing two datables and I get a 2 Datatable i need to match Columns and Row by D_ID and find the difference between the two values (columns are of string type)
I want to loop through table1 D_ID and find the same in table2 and then loop through column (match)and find the difference

Table 1
D_ID
Split
Value_1
Value_2
Value_3
N6K_12

Str
1.503

9.5E-03

-0.48

N6K_13

Ref
1.680

6.5E-03

-0.63

N6K_14
 
St
1.690
 
3.3E-03
 
-0.43
 
N6K_15
 
Ref
1.903
 
4.5E-03
 
-0.83
 


 table 2 - column D_ID is not in same order as table1 

D_ID
Value_2
Value_1
Value_3
N6K_14

3.503

2.5E-03

-3.48

N6K_13

5.680

2.5E-03

-1.63
N6K_15
 
4.690
 
5.3E-03
 
-0.63
 
N6K_12
 
8.903
 
5.5E-03
 
-4.83
 

 Output table

D_ID
Split
Value_1
Value_2
Value_3
N6K_12

Str
(1.503)- ( 5.5E-03)
 
 


(-0.48)-( -4.83)

N6K_13

Ref
(1.680)-( 2.5E-03)



N6K_14
 
St
(1.690)-( 2.5E-03)



N6K_15
 
Ref


(-0.83)-( -0.63)




Answers (12)