DataTable filtration problem - get all headers of columns with specific value in specific cell

Hi,
how to get all headers of columns with specific value in specific cell?

I have a problem with filtration of datatable. I’ve got file “config” with all information who sends an email to whom.
CONFIG.xlsx (13.6 KB)

My workflow look like that:

  1. User write his email adress (by “InputDialog”)
  2. Robot read range from file “CONFIG.xlsx” and put it to DT_1
  3. For each row in DT_1 -> if -> row(“email”).ToString=user_email
    and what now?
    I want to get all headers of columns with cells contains “1” in this specific row
    How to filtrate it next?

@Sevlir I can think of a few ways to do it. But can you give a gist of what you will be doing with the columns that have 1 in them? Based on that I can suggest what suits best for you.

@Sevlir

Could you please help me to understand issu e correctly,

I understood following, correct me if i am wrong

  1. Read config file and store into dt1 (dt1 is datatable variable)
  2. Ask user to input email id via input dialog box and store value in userEmail (userEmail is string type variable)
    3.then robot will check userEmail is present in dt1
    Use following equation in try catch and catch invalidoperationexception (email isnot in dt1)
    Dt2 = dt1.Asenumerable.where(function ® r(“email”).tostring.toupper.trim.equals(userEmail.tostring.trim.toupper)).copytodatatable

Dt2 is output
Is this right?

1 Like

The number “1” in column means that this is a company that robot will send a message. It is a simple matrix where 2 conditions must be met. I’m using read range because client want to have an option to change it freely of file “CONFIG”.

Yes but I only used “row(“email”).ToString=user_email” in “If” activity and I don’t know that to do next.
With this command I have the row I need.
And now I need all headers of columns with “1” in it for that specific row.
The number “1” in column means that this is a company that robot will send a message in next steps.

Use another if inside the row(“email”) if condition
Row(“one”).tostrng.equals(“1”) and so on…

1 Like

Is it what you want?

Almost because client want to have possibility to add more columns. I’m looking for solution to find column header if this column contains in row (with user email) number “1”. It is a simple matrix where 2 conditions must be met.

Keynote here is to find by robot all column headers for row with email address user give in the beginning. Headers are another email addresses where robot will be sending messages.

Use assign stage
(Colums is string array)
Colums = dt.Columns.Cast(Of DataColumn)().[Select](Function(x) x.ColumnName).ToArray()

This will return all column names now, you juat need to loop

1 Like

I have to use it inf “If” activity?
Like this:
If: row(“email”).ToString=user_email
Than: assign
Colums = dt.Columns.Cast(Of DataColumn)().[Select](Function(x) x.ColumnName).ToArray()
???

In my openion you have to use assign stage immediately after reading config file and before foreach

1 Like

Is this all written in VBA?
Do You maybe know where can I find commands which work in UiPath. I’m asking because I quite don’t understand how Your command works.

please refer this workflow.
Main.xaml (14.6 KB)

1 Like

@Sevlir
Is this what you want?

WOW!!! Thank You very much!!!

1 Like

No problem

1 Like

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