Linq to Extract a required value

Hi All,
Good Day!

I Have a Data table, if the column has a specific value i need to extract other 2 column values,
For Example,
image

In the above image,
if the “type” is “O” i need to extract “Date” value and “Created” value.
I need a linq for this one,

Can someone help me with this?

Thanks in Advance :slight_smile:
Regards,
Soundarya

in general it is a filter task which we can do with essential or with the LINQ Where operator

Assign Activity:
myRow | DataRow =

dtData.AsEnumerable.Where(Function (x) x("Type").toString.Trim.Equals("O")).FirstOrDefault()

if myRow is not null (as it was found) we use
myRow(“Created”).toString eg. to get the value

UPD1 -

  • maybe the extraction into a dict will better serve later for the access and would be possible
  • when it can happen that the data does have more O rows, then we would adapt the LINQ as well

UPD2:
for learning have a look here:

1 Like

Hi @soundarya_A1

If you want to store the two column values in two different variables. Then check the below flow,

→ Use Read range workbook activity to read the excel and store in a datatable called DT.
→ Then create two variables called Date and Created to store the values in those variables.
→ Take two assign activities and write the below expressions,

- Assign -> Date = DT.AsEnumerable().Where(Function(row) row("Type").ToString().Equals("O")).Select(Function(row) row("Date")).FirstOrDefault()

- Assign -> Created = DT.AsEnumerable().Where(Function(row) row("Type").ToString().Equals("O")).Select(Function(row) row("Created")).FirstOrDefault()

Hope it helps!!

1 Like

@soundarya_A1

please check with this

inside For Each row in data table

Assign: GetDate(variable): If(CurrentRow(“Type”).ToString = “O”, CurrentRow(“Date”).ToString, Nothing)
Assign: Created(variable): If(CurrentRow(“Type”).ToString = “O”, CurrentRow(“Created”).ToString, Nothing)

1 Like

Thanks for the solution!
Appreciate it @ppr

Thanks for the approach :slight_smile:

1 Like

Thanks for the approach!

1 Like

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