Group Data Table

Hello Team i have a query related to Excel i am having multiple data on a column so i want to pick only one from that multiple value and also unique value from them.

Thanks in Advance…

@Darkfighter,

You got two options here:

Method 1: Using DefaultView.ToTable

  1. Read Range: Use Read Range activity to read your Excel sheet into a DataTable, say yourDT.
  2. Assign Activity: Use the following LINQ query to filter out the distinct values:
yourDT = yourDT.DefaultView.ToTable(true, "ColumnName")

Method 2: Using LINQ and GroupBy

  1. Read Range: As before, use Read Range to load your Excel data into a DataTable.
  2. Assign Activity: Assign a new DataTable with unique values:
yourDT = yourDT.AsEnumerable().GroupBy(Function(r) r.Field(Of String)("ColumnName")).Select(Function(g) g.First()).CopyToDataTable()

This method uses LINQ to group by the column values and selects the first unique occurrence.

LLM helped me to rephrase the answer but it’s validated by me

2 Likes

Hi @Darkfighter

Check below workflow modify accordingly:

Happy Automation!

Hey @prashant1603765 thanks for the detailed steps.it really helped me out. :victory_hand:

1 Like

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