Search code examples
rpauipath

Values from a column in UiPath - Need most efficient way


In UiPath, what’s the most efficient method to get a list or array of all the unique values in a column from a DataTable? Preferably without looping


Solution

  • I think what you want to do is to implement a UiPath filter based on a single column with something like this:

    yourDT.DefaultView.ToTable(true, "ColumnName")
    

    You can scale this to do multiple column filters as well by simply adding extra column names:

    yourDT.DefaultView.ToTable(true, "ColumnName1", "ColumnName2"...."ColumnNameN")
    

    Efficiency vs simplicity

    By the way, the discussion of what's 'most efficient' is debatable. I'd say these are the simplest approaches. I'm sure there's some genius out there who could write their own code to shave some clock cycles off the default implementation. But for combined efficiency and simplicity, this is the way to go.