How to filter specific data from a datatable?

I have a data table generated from a read range activity that kinda looks like this:

Capture

Now based on the input, I want to display values from the specific cell, like if the product is X and if the price is USD is asked then I must return 10.

How do I do this? I’m able to filter columns individually but, I’m not able to filter them by specific row. Kindly help!

You can use For Each Row activity, and then you can use row(“Price in USD”) to check the price or any other information.

This is still giving me all the rows’ value. I want to extract info based on two inputs only like Prod Y and USD should return 15. I kinda want to make it work like “read cell” activity but from the inputs I give.

Hi @monsieurrahul
Use Following Linq query to filter datatable.
dt.AsEnumerable().Where(Function® CStr(“yourcolumnName”).Equals(“Value”) And CStr(“YoursecondColumn”).Equals(“SeconValue”)).CopyToDataTable

@monsieurrahul,

you can use select query.
image
Main.xaml (8.0 KB)

1 Like

This is fine but, please note that the column containing the products doesn’t have a name so, how can I filter using the column name “Products”?

Use Indexing for column 1 use " (0)"

Get_specific_data.zip (7.4 KB)

Please refer this Xaml.

reqRow = testDt.AsEnumerable().where(Function(x) x(0).ToString.Equals(“Prod X”)).FirstOrDefault()

This will return required datarow. From which we can get the required value.

Thanks!

1 Like

This works but, can you please explain the same in simple words?

@venkat4u thanks! This was a pretty close solution but, I really appreciate the time and effort you’ve taken in sharing the workflow.

  1. Read Range to get the input datatable from excel
  2. Getting the specific datarow from dt using the following linq,
    reqRow = testDt.AsEnumerable().where(Function(x) x(0).ToString.Equals(“Prod X”)).FirstOrDefault()
  • this will return the exact row by looking the first column(index=0) = “Prod X”. It will validate this input string with all the rows. If it matches then it will return the whole datarow.
  • Then we can get the value of usd or inr by calling them via index
  • usd = reqRow(1).ToString
  • inr = reqRow(2).ToString

Note : you can pass this string “Prod X” as dynamic variable inside the above linq. It will return value as per the dynamic variable.

Thanks!