Remove or add data

Hi friends,

I have an excel with sl no, Ui no, status, acc no, name, acc holder,
If I have two acc no’s same and acc holder is joint then I need to take any one data among those.

If I have two acc no’s same but one acc holder is joint and other acc holder is main i need to take only main data.

If I have two acc no’s same but one acc holder is main and other acc holder is joint i need to take only main data.
I need to write back the whole data back to excel.

How to achieve this. Please help me

Hi @0bb4628e217fd43ac86ac9294

Can you an sample input and expected output.

Regards

@0bb4628e217fd43ac86ac9294

Can you share the sample input and output

Can you please help me

@0bb4628e217fd43ac86ac9294

(From row In DT.AsEnumerable()
                               Group row By accNum = row.Field(Of Double)("Account Number") Into grp = Group
                               Let selectedRow = grp.Where(Function(r) r.Field(Of String)("Account Holder").Equals("MAIN HOLDER")).FirstOrDefault()
                               Select If(selectedRow IsNot Nothing, selectedRow, grp.First())
                              ).CopyToDataTable()

Hi @0bb4628e217fd43ac86ac9294

You can use the Group by in the LINQ Expression to get the expected result,
→ Use the Read Range workbook activity to read the excel and store in a datatable variable called Input_dt.
→ Use the assign activity to write the below LINQ Expression,

- Assign -> Input_dt = (From row In Input_dt.AsEnumerable()
                        Group row By AccNo = row.Field(Of Double)("AccNo") Into Group
                        Let mainRow = Group.FirstOrDefault(Function(r) r.Field(Of String)("AccHolder").ToLower() = "main")
                        Select If(mainRow IsNot Nothing, mainRow, Group.First(Function(r) r.Field(Of String)("AccHolder").ToLower() = "joint"))
                                       ).CopyToDataTable()

→ Use the write range workbook activity to write the Input_dt to the excel.

Check the below workflow for better understanding,
Sequence.xaml (12.3 KB)

Input -
image

Output -
image

Hope it helps!!

Thank you for your help it’s working

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