DataTable for Duplicate Rows

Hi, the workflow is currently reading an Excel file as below.
I would like to know, what are the ways to send out an email only once to Ben when there are more than one row for Ben.

image

Currently, I am using an approach suggested, which is :

image

However, I am not sure how to select the right “CC”.

Thank you.

@SukhvinWalia

Try below steps

  1. Read Range (Excel File)- output - dtSheet1

  2. Assign Activity → dtNew(DataTable) = dtSheet1.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(“Name”)).Select(Function(b) b.First).CopyToDataTable()

  3. Write range → Wirte dtNew to “Sheet2” → You will get new datatable(dtNew) with Unique rows.

  4. Again Read Range → Sheet2

  5. Use for each row to iterare on dtNew-> Send mail to each person once.

you can skip steps 3 and 4 and directly iterate over dtNew to send mail.

1 Like

@SukhvinWalia

Try below expression.

( From row in dtInput Group row by a = row("Name").ToString.Trim into grp = Group Where grp.Count > 1 Select grp.First ).CopyToDataTable

Note: Here, dtInput holds your input data and it is of type DataTable.

1 Like

Hi @SukhvinWalia

Try this below expression

(From p in DT.Select() where( From q in DT.Select() where q("Column Name").Equals(p("Column Name)) Select q).ToArray.Count>1 Select p).ToArray.CopyToDataTable()

DT is an Input Data Table

Regards
Gokul

1 Like

@SukhvinWalia
Please mark as solution if its resolved your problem.

Hi @SukhvinWalia,

The approach you are using will provide you the unique values only from the column HOD and not others, To get the email you can follow the approaches provided by my fellow mates over.

to take multiple columns you can separate them by , values like “HOD”,“Email”

Thanks

1 Like

Thank you. It works.

Thank you. It works too.

1 Like

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