How to get the first value of a filtered table?

datatable
excel
activities

#1

Hi!

So, I’ve used the Filter Table activity and I got a result of around 5 rows. I need to retrieve only value from the first row that appears, but since the cell number is variable (Sometimes it may be “L12”, sometimes “L15”, etc) I can’t use the “Read Cell” Activity. The column will always be the same, though.

Any ideas on how to approach this?

Thanks!


#2

Hi,

Try using the Read Range. I’m assuming it’s filtering it on the spreadsheet, so if you use Read Range to a Data Table variable, then you can access each row directly.

For example,
datatablevariable.Rows(0).Item(“L12”).ToString

(0) tells it to use the first row - (1) would be the second row, etc
and .Item(“L12”) is the column.

Regards.


#3

Hi Clayton!

I got the gist of your idea, but I’m not entirely sure on how to implement it. I’ve used the Read Range activity to read the whole sheet and then the assign activity to introduce what you wrote there. Was that your idea?

Capture

I got the following error while trying it:
Assign : Column 'L12 does not belong to table.

Thanks a lot for the help!


#4

Sorry that was my fault. “L12” should have been the Column name instead.
So basically it is datatable.Rows(rowindex).Item(columnindex).ToString

If you use “Add Headers” in the properties of your Read Range you can use the column names found on the spreadsheet. However, that is only if your spreadsheet has column names. Otherwise, you need to use a numeric value that represents that column, like 0 for A, 1 for B, 2 for C, and so on.

datatable.Rows(0).Item(0).ToString
^that will return the first row and first column

datatable.Rows(0).Item(1).ToString
^that will return the first row and second column

datatable.Rows(0).Item(“Valor”).ToString
^that will return the first row and the column with header “Valor” assuming you have a Valor column header

Hopefully that made more sense.

Thanks.

C