I think you meant Table 1 and Table 2 are the Input tables (given) and table 3 is the Output table (desired results)
Maybe something like this...
[TABLE="class: grid"]
<tbody>[TR]
[TD="bgcolor: #DCE6F1"][/TD]
[TD="bgcolor: #DCE6F1"]A
[/TD]
[TD="bgcolor: #DCE6F1"]B
[/TD]
[TD="bgcolor: #DCE6F1"]C
[/TD]
[TD="bgcolor: #DCE6F1"]D
[/TD]
[TD="bgcolor: #DCE6F1"]E
[/TD]
[TD="bgcolor: #DCE6F1"]F
[/TD]
[TD="bgcolor: #DCE6F1"]G
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]1
[/TD]
[TD]Table 1
[/TD]
[TD]Revenue
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]2
[/TD]
[TD]SN
[/TD]
[TD]Invoice no.
[/TD]
[TD]Customer
[/TD]
[TD]description
[/TD]
[TD]amount Dollar
[/TD]
[TD]exchange rate
[/TD]
[TD]amount euro
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]3
[/TD]
[TD]158958
[/TD]
[TD]15RD000268
[/TD]
[TD]ASD
[/TD]
[TD]process_fee_23.04-22.05.2017_SN_158958
[/TD]
[TD]38.850,00
[/TD]
[TD]1,2361
[/TD]
[TD]31.429,50
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]4
[/TD]
[TD]158958
[/TD]
[TD]15MD000158
[/TD]
[TD]ASD
[/TD]
[TD]registration_fee_01.03-31.03.2017_ESN_158958
[/TD]
[TD]57.722,00
[/TD]
[TD]1,2323
[/TD]
[TD]46.840,87
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]5
[/TD]
[TD]158958
[/TD]
[TD]15RC000158
[/TD]
[TD]ASD
[/TD]
[TD]process_fee_23.04-22.05.2017_ESN_158958
[/TD]
[TD]2.102,00
[/TD]
[TD]1,2323
[/TD]
[TD]1.705,75
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]6
[/TD]
[TD]158958
[/TD]
[TD]15MC000159
[/TD]
[TD]ASD
[/TD]
[TD]registration_fee_01.03-31.03.2017_ESN_158958
[/TD]
[TD]5.541,00
[/TD]
[TD]1,2323
[/TD]
[TD]4.496,47
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]7
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]8
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]9
[/TD]
[TD]Table 2
[/TD]
[TD]Cost
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]10
[/TD]
[TD]SN
[/TD]
[TD]Invoice no.
[/TD]
[TD]Customer
[/TD]
[TD]description
[/TD]
[TD]amount Dollar
[/TD]
[TD]exchange rate
[/TD]
[TD]amount euro
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]11
[/TD]
[TD]158958
[/TD]
[TD]SAEL-18-0036-04
[/TD]
[TD]ASD
[/TD]
[TD]process_fee_10.04-09.05.2017_SN_158958
[/TD]
[TD]37.233,49
[/TD]
[TD]1,2308
[/TD]
[TD]30.251,45
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]12
[/TD]
[TD]158958
[/TD]
[TD]200-PANIN-000058
[/TD]
[TD]ASD
[/TD]
[TD]registration_fee_01.03-31.03.2017_SN_158958
[/TD]
[TD]82.483,14
[/TD]
[TD]1,2321
[/TD]
[TD]66.945,17
[/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]13
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]14
[/TD]
[TD]Table 3
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]15
[/TD]
[TD]SN
[/TD]
[TD]PF (Revenue)
[/TD]
[TD]RF (revenue)
[/TD]
[TD]PF (cost)
[/TD]
[TD]RF (cost)
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD="bgcolor: #DCE6F1"]16
[/TD]
[TD]158958
[/TD]
[TD]29.723,74
[/TD]
[TD]42.344,40
[/TD]
[TD]30.251,45
[/TD]
[TD]66.945,17
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
Values in blue
Formula in B16
=SUMPRODUCT(--($A$3:$A$6=A16),ISNUMBER(SEARCH("RD",$B$3:$B$6))*$G$3:$G$6-ISNUMBER(SEARCH("RC",$B$3:$B$6))*$G$3:$G$6)
Formula in C16
=SUMPRODUCT(--($A$3:$A$6=A16),ISNUMBER(SEARCH("MD",$B$3:$B$6))*$G$3:$G$6-ISNUMBER(SEARCH("MC",$B$3:$B$6))*$G$3:$G$6)
It's not clear what are the criteria to get the values in red (D16 and E16). Could you clarify?
M.