Comparing Rows in same data table

Hi Team
I need support for comparing two rows in same data table
in two collumn first is invoice and second is Status.the issue is if one invoice number status is fail then for same invoice number in second row the status we need to make fail
please help to resolve
thanks in advance


Could you show the output you would like to get?


in sr no 4 invoice no is 71 and status is failed
in sr no 5 invoice no is 71 and status is failed it should change to failed
same for sr no 6 invoice number is 74 and status is failed to
from sr no 7 to 11 status should change as failed


Example solution
Tester.xaml (12.6 KB) Test.xlsx (8.3 KB)

  1. read excel

  2. create list of unique invoice numbers

  3. create a dictionary.
    a) Then for each unique invoice, check if the table contains a row with that invoice where status = fail,
    b) if a row is found, then add entry to dictionary where key = invoice, value = fail,
    c) otherwise add entry where key = invoice, value = success

  4. update datatable with new values from dictionary

  5. write new dt to excel

(left = original excel, right = result excel)

Thank you so much for support

1 Like

i am facing one more issue while comparing
Assign: Specified cast is not valid.",

an alternative method using LINQ and Lambda expressions

Step 1/ get InvoiceNr of records with failed status
Step 2/ update source DT

OuterJoinAndReplace.xaml (8.2 KB)
dt.xlsx (8.3 KB)


can you send me the excel you are using if its still not working?

its working for me, what format is your invoice no. column?


This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.