How can I filter a DataTable using dynamic filters that change each time, including complex AND/OR logical conditions?
Hi @Sal23,
You can achieve dynamic DataTable filtering using the Select() method or Filter Data Table activity by building the filter condition string dynamically at runtime.
For complex AND/OR conditions, the Select() method is usually more flexible.
Example:
filterCondition = "Status = 'Open' AND (Department = 'IT' OR Department = 'HR')"filteredRows = dtData.Select(filterCondition)filteredDT = filteredRows.CopyToDataTable()
You can dynamically build filterCondition using variables based on user input or configuration values.
Example dynamic build:
filterCondition = "Country = '" + countryVar + "' AND Age > " + ageVar.ToString
This approach works well when filters change frequently and include nested AND/OR logic.
Hi @Sal23
You can filter a DataTable dynamically by building the filter condition as a string at runtime based on your inputs, including AND/OR logic, and then applying it using the Select() method. For more complex scenarios, you can use LINQ where you define conditions programmatically. In simple terms, you create the filter dynamically depending on user input and apply it to get the required filtered data.
For now, i use a conversational agent to generate select request from the need of the user, after that, i pass the select request to a rpa workflow that will apply it inside the select
what do you think guys about this solution ?
i added a tool to this agent to map the names of the names of the columns
That make sense, you can get the condition filters from the user as it stored in variable and that variable passed in your workflow. and just a question why you are using conversational agent. if just getting the condition filters from the user in rpa workflow itself you can use the input dialogue box
Because i’m trying to build an agent to communicate with an advisor,
the advisor can question the agent about clients, transactions, … (excel files / history of conversations pdf files)
and the agent should be capable to answer,
i’m gonna give you examples :
the advisor needs a list of clients with conditions : client nationality is X and clients age is greater than Y
here the agent should understand the need and do the treatment and return a response
another example can combine many files :
the advisor want to list the data of the client who did the transaction number A,
here the agent should combine treatment of 2 or 3 files to find the response,
this is why i’m trying to use the conversational agent,
but i’m still concerned about the architecture of my projet.
Hi @Sal23 ,
Your approach is good, especially keeping the conversational agent for intent understanding and query generation while RPA handles the execution.
My suggestion would be:
- Let the agent only identify intent, filters, and column mappings
- Keep joins, validations, and data processing in workflows/backend logic
- avoid giving direct execution freedom to the LLM
- keep business rules outside the model as much as possible
For multi-file scenarios, define common keys (ClientID, TransactionID, etc.) instead of letting the LLM guess relationships dynamically.
This architecture will be more scalable, reliable, and easier to maintain long term.
in my case with many excel files with a relation between files, do you think using a database will be more efficient ?
creating a database and tables using rpa workflows,
after that, the agent communicate with the user, and it will generate sql requests,
and thay will be executed using rpa workflow and recuperating the results
Till now what you are following the approach is correct to meet your business requirement, So as you mentioned there are lot files you need to handle, in that case instead of depending on the excel files you can use data base but
Do not create the table for each sheet or for 1 day files. you can a database and maintain one master table in that you can add all excel file records, and also you can add the status of that record, if incase in future if you want those you can easily get those.
Or if you dont need once processed data, store your files in central location and do the automation one by one.
If you can use database that was better approach.
Happy Automation
YK