Check duplicate data and get last data row

Helloe everyone,
I’ve a question for this example case

dtUsed:
Name, Amount, Tag
Dog, 1, Dog_X
Cat, 10, Cat_Y

dtMaster:
Name, Amount, Tag
Dog, 1, Dog_A
Dog, 2, Dog_B
Cat, 10, Cat_A
Cat, 10, Cat_B

So the dtUsed will be replaced like this:

Expected output: dtUsed
Name, Amount, Tag
Dog, 1, Dog_A
Cat, 10, Cat_B

Anyone can help to solve?

Regards,
Brian

Hi @Brian_Henokh1

Take an assign activity and create a datatable variable called Output_dt,

- Output_dt = dtUsed.Clone()

Use the below linq expression,

- Assign -> Output_dt = (
                         From a In dt_Used
                         Join b In dtMaster
                         On a("Name").toString Equals b("Name").toString and a("Amount").toString Equals b("Amount").toString
                         Select Output_dt.Rows.Add({a("Name"),a("Amount"),b("Tag")})
                            ).copytodatatable

Hope it helps!!

1 Like

EDITED/ADDED:

  • Extended Grouping on Name, Amount
  • Use Case Tracker

Assign Activity:
dtResult =

(From d In dtMaster.AsEnumerable
Group d By k1=d("Name").toString.ToUpper.Trim, k2=d("Amount").toString.ToUpper.Trim Into grp=Group
Let arrCV = New String(){k1,k2}
Let chk = dtUsed.AsEnumerable.Any(Function (x) New String(){"Name","Amount"}.Select(Function (m) x(m).toString.ToUpper.Trim).SequenceEqual(arrCV))
Where chk
Select r=grp.Last()).CopyToDataTable
1 Like

thank you for your response, the output I tried is
[Name,Amount,Tag
Dog,1,Dog_A
Cat,10,Cat_A
Cat,10,Cat_B
]

Sorry I didn’t get you could you elaborate more… @Brian_Henokh1

vs

vs.

get Last Data Row (Title)

So what is needed in detail?

this syntax is worked well sir :100:
thanks in advance

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