How do I read a DataTable value and return the value of another column?

Hey there,

I need to find if a cell of a Data Table contains the word ‘Ply’ (it may be part of a full value, eg: Ply-Lining CDV (Network)) and then if it does, get the value in the column next to it, which will be the cost of the item.

So eg DT:
image
(This won’t be in excel, of course)

It needs to realise that ‘ply’ is in Col 1 and return £300 in Col2

How would I do this? My Data table variable is set to pDT.

Thank you for your help!

do a start with filtertable activity and using the contains operation

Hey!

Try this

  1. Read range output - pDt
  2. Read range output - ResultDt (This is for headers)
  3. Take one for each row in data table and pass the pDt and create the rowindex variable in the properties panel
  4. Take one if condition and pass the expression like this
CurrentRow("Col1").ToString.Trim.Contains("ply")

Now take one assign activity in the then block pass the value like this

ResultDt.Rows(RowIndex_Dt1).Item("Col1") = dt1.Rows(RowIndex_Dt1).Item("Col2").ToString.Trim

Now use write range provide the dt as ResultDt → Chcek AddHeaders

Try this and let me know

Regards,
NaNi

Is that not just for excel? I shan’t be working with excel in this case!

For each row, then ‘If’ row(0).ToString.Contains(“WORD”)

Assign: DesiredValue = row(“Column2”).ToString

Str=DT.Asenumerable.Where(Function(r) r(0).Tostring.Contains(Your_String)).First().Item(1).Tostring

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