top of page

How to retrieve unique values from a data table faster and more efficiently

💡 Are you using a For Each action to retrieve unique values from a data table? What if I tell you that there is a faster and more efficient method? Read on to learn more about this hack.

Problem Description


Retrieving unique values from a data table using the "For Each" action may require multiple actions and lead to slower processing within a loop.


Assume you have a data table called '%DataTable%' with columns for names and email addresses.



Solution


The following flow provides a high level overview of the solution:


We will use the “Run .NET script” to perform the checks and returns a data table. Configure the following:

  1. Language: C#

  2. .NET script imports:



  3. Script parameters:


  • Click “Edit



  • Click ‘+’ icon at the bottom left to add parameters



  • Add the following two parameters:



  • Add the following code under ‘.NET code to run:



  • This code creates a new datatable containing only unique rows based on the "Email" column from an existing datatable. Here's a breakdown of its function:

    • Cloning the datatable: uniqueValuesTable is created with the same structure as the original datatable.

    • Looping through rows: It iterates through each row in the original datatable.

    • Checking for uniqueness: For each row, it checks if the "Email" value already exists in uniqueValuesTable.

    • Adding unique rows: If the "Email" value is not found in the new table, the row is added to uniqueValuesTable.

    • Result: After processing, dataUniqueEmail contains rows with unique "Email" values.


This will allow you to achieve the desired output:



Additional Information


  • Last updated on: 5 Dec 2024

  • Tested version(s): 2.50.00183.24303

  • Prerequisites: Datatable

  • Dependencies: None

  • Known issues: None

References


Nil

Robotic Process Automation Singapore

CFB Bots is a leading technology service provider in the fast-growing field of Intelligent Automation. We partner with large enterprises in their Digital Transformation journey and help them and their employees thrive in the Future of Work.

NAVIGATE
CONTACT US
STAY CONNECTED

Singapore

CFB Bots Pte Ltd

Registration No.: 201705263H

77 High Street

#05-09, High Street Plaza

Singapore 179433

T: +65 6909 2099

E: enquiries@cfb-bots.com

Malaysia

CFB Bots Sdn Bhd

Registration No.: 202401045826 (1591672-X)

Suite: 33-01, 33rd Floor

Menara Keck Seng

203 Jalan Bukit Bintang

55100 Kuala Lumpur

T: +60 39 388 0352

E: my@cfb-bots.com

Australia

T: +61 2 8880 5998

E: au@cfb-bots.com

Join our mailing list to get the latest insights on automation

  • LinkedIn Social Icon
  • Facebook Social Icon
  • Twitter Social Icon
  • Instagram Social Icon
  • YouTube Social  Icon
TS Master Logo.png

© 2017-2025 CFB Bots Pte Ltd. All Rights Reserved. Tel: (65) 6909 2099 | Email: enquiries@cfb-bots.com | Privacy Policy | Terms of Use

bottom of page