Filter datatable with non sensitive value

Is it possible to use the filter datatable function but make it so that it isn’t case sensitive. For example if the input is ‘apple’, it should still keep ‘APPLE’ or ‘Apple’ or any other variations within the datatable.

If it could be done directly using Filter Data Table activity from UiPath.System.Activities it would be for the best.

I was suggested by chatGPT to use

Assign activity:
  To: myDataTable
  Value: myDataTable.Select("Column1.Equals('apple', StringComparison.OrdinalIgnoreCase)", "Column1", DataViewRowState.CurrentRows).CopyToDataTable()

When I use the following

Value: DataTable.Select("(Contact Name).Contains('tan', StringComparison.OrdinalIgnoreCase)", "Contact Name", DataViewRowState.CurrentRows).CopyToDataTable()

It return the following error

Source: Assign
Message: Syntax error: Missing operand after 'Name' operator.

Appreciate any and all advice.

Thank you.

1 Like

Filter data table without Case sensitive values - Help - UiPath Community Forum

Try with this in a assign activity

filteredData = yourDataTable.AsEnumerable().Where(Function(row) NOT row("ColumnName").Equals("apple", StringComparison.OrdinalIgnoreCase)).CopyToDataTable()

This query will remove rows with the exact lowercase “apple” but keep rows with variations in case like “Apple” or “APPLE.”

hope this helps

Cheers @QTH

Hello @QTH

Assign activity:
To: myDataTable
Value: myDataTable.AsEnumerable().Where(Function(row) row.Field(Of String)(“Contact Name”).IndexOf(“tan”, StringComparison.OrdinalIgnoreCase) >= 0).CopyToDataTable()

Thanks & Cheers!!!

I would need it to keep all variations of the input, so in this case ‘apple’ as well.

Encountered the following error

22.10.5+Branch.support-v22.10.Sha.79bc7c61a909d990afd07620b3005b3a35eb1f1b

Source: Assign

Message: Object reference not set to an instance of an object.

Exception Type: System.NullReferenceException

System.NullReferenceException: Object reference not set to an instance of an object.   at lambda_method(Closure , DataRow )
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Data.DataTableExtensions.LoadTableFromEnumerable[T](IEnumerable`1 source, DataTable table, Nullable`1 options, FillErrorEventHandler errorHandler)
   at System.Data.DataTableExtensions.CopyToDataTable[T](IEnumerable`1 source)
   at lambda_method(Closure , ActivityContext )
   at Microsoft.VisualBasic.Activities.VisualBasicValue`1.Execute(CodeActivityContext context)
   at System.Activities.CodeActivity`1.InternalExecuteInResolutionContext(CodeActivityContext context)
   at System.Activities.Runtime.ActivityExecutor.ExecuteInResolutionContext[T](ActivityInstance parentInstance, Activity`1 expressionActivity)
   at System.Activities.InArgument`1.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance activityInstance, ActivityExecutor executor)
   at System.Activities.RuntimeArgument.TryPopulateValue(LocationEnvironment targetEnvironment, ActivityInstance targetActivityInstance, ActivityExecutor executor, Object argumentValueOverride, Location resultLocation, Boolean skipFastPath)
   at System.Activities.ActivityInstance.InternalTryPopulateArgumentValueOrScheduleExpression(RuntimeArgument argument, Int32 nextArgumentIndex, ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Boolean isDynamicUpdate)
   at System.Activities.ActivityInstance.ResolveArguments(ActivityExecutor executor, IDictionary`2 argumentValueOverrides, Location resultLocation, Int32 startIndex)
   at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

@QTH

if using linq queries you can cast both sides and then compare

dt.AsEnumerable.Where(function(x) x("ColumnName").ToString.ToLower.Trim.Equals("apple")).CopyToDataTable

cheers

Can u give an example on this @QTH

As in your provided solution mentions that it will remove ‘apple’ but retain all other variations. I’m just sharing I need all variations include the original input which is ‘apple’ in that example.
So, ‘apple’, ‘Apple’, ‘APPLE’ all being retained in the datatable was my desired outcome.

@QTH

  1. Check that your variables are properly initialized.
  2. Verify data availability and extraction.
  3. Validate selectors for web elements.
  4. Implement error handling for empty results.
  5. Use logging and debugging to pinpoint the issue.
  6. Examine the exception details for specific clues.

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