Length of particular column value

In a datatable

ColumnA ColumnB
12345 Yuiu
67890 Passed
13456 Uubn
12445 Uujjk
13346 Hujj
13478 Uujjb

To find Column A values all has same length or not…Ned boolean as ouput

Hi @Demo_User

To determine whether all values in Column A have the same length or not, you can use the following workflow in UiPath:

  1. Read the datatable into a variable, let’s call it dt.
  2. Add a new Boolean variable, isSameLength, to store the result.
  3. Use an Assign activity to set the initial value of isSameLength to True.
  4. Use a For Each Row activity to iterate through each row in the datatable.
  5. Within the loop, add an If activity to check the length of each value in ColumnA against the length of the first value. You can use the Len function to get the length of a string.Condition: Len(row("ColumnA").ToString) <> Len(dt.Rows(0)("ColumnA").ToString)If the lengths are not equal, set isSameLength to False and break the loop using the Break activity.
  6. After the loop, use an Output Data Table activity to display the result.



How about the following?


dt.AsEnumerable.GroupBy(Function(r) r("ColumnA").ToString.Length).Count=1


Sample20230522-5aL.zip (2.8 KB)


As a variation

YourDataTableVar.AsEnumerable.Select(Function (x) x("ColumnA").toString.Trim.Length).Distinct().Count=1

Hi @Demo_User

  • Read Range (Specify Excel file and range)

    • Output: DataTableVariable
  • Assign (Boolean) (allSameLength = True)

  • For Each Row (DataTableVariable)

    • If (Not row(“ColumnA”).ToString.Length = previousRow(“ColumnA”).ToString.Length)
      • Assign (allSameLength = False)
  • Assign (Boolean) (OutputVariable = allSameLength)

Hope it helps!!

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