Filter Data Table Column Field

excel
filter-datatable

#1

Hi,
I am using Filter Data Table activity to filter my Excel file. In ‘Column’ field from “filter data table activity” I want to enter my Column name starts with ‘N’… (i.e) “Name”.
Please help me to find out my column name starts with ‘N’ in the Excel File…
filter1

Thanks,
Arunachalam


#2

Hi @Arunachalam,

  1. Create a string variable .
  2. Before the Filter data table activity, get the column and assign it.
  3. Use the variable in the Column of Filter Wizard, like below.

Regards
Balamurugan.S


#3

Hi @balupad14

I have tried that way. But my problem is how to find out the “column name” starts With ‘N’. Do you know any query to start with ‘N’, and place this query value in the Column Field.

Thanks,
Arunachalam.


#4

Hi @Arunachalam,

Check this

dtExcel.Columns.Cast(Of DataColumn)().Where(Function(a)  
a.ColumnName.StartsWith("N")).Select(Function(a) a.ColumnName).ToList()

Note :

If you need only one result, instead of ToList() can use FirstOrDefault()

Regards
Balamurugan.S


#5

Hi @balupad14

It’s worked… Thank you for your Exact Answer.


#6

Hi @balupad14

My second Doubt is how should I use That “List” variables inside the Column Field. When I use First or default method it’s type is string, But List value how can I use?


#7

i did not understand your question :frowning: the result of a where is a list… of Columns and you can work with them. If you want to go through each column you can use for each if you want to get first/last item you just use .last or . first :slight_smile: if you want to know how many items it contains you can use .count

In the case you want to get exactly one column just use the same expression used before but change startsWith to .equals(“Name”)


#8

Hi @Arunachalam,

The List value is having the list of string values. It is look like array string. Both are not equal.

Regards
Balamurugan.S


#9

Hi @balupad14,

Yes I aware of that. but if I want to iterate the list, I need to use “For each Activity” Right.


#10

Yes .


#11

Hi @balupad14,

“dtExcel.Columns.Cast(Of DataColumn)().Where(Function(a)
a.ColumnName.StartsWith(“N”)).Select(Function(a) a.ColumnName).ToList()”
From this query, How you are using Functions, How can I learn… Do you have any link for learn this?

Thanks,
Arunachalam.


#12

Hi @Arunachalam,

It is Linq. When you go to search Linq Vb.net. You will get many links.

Regards
Balamurugan.S


#13