ainaasyhda
(Ainaa Syuhada)
August 29, 2023, 6:59am
1
Hi I want to filter the datatable get from excel.
Instead of filtering using the column name, I want to sent the column name as variable which the colum will be varied.
I assign a variable to represent the column which the colum is date
And I write the Expession in the filter assign like this :
I tried this method however failed. Kindly advised on how should I use this filter method with variable
@ainaasyhda
datatablevar.select(“[variable]=‘Value’”).copytodatatable
or you can try below
datatable.asenumerable.where(function(r) r(“ColumnName”).tostring=“OD”).copytodatatable
cheers
ainaasyhda
(Ainaa Syuhada)
August 29, 2023, 7:17am
3
Hi thank you for your reply, however still could not found the table name with using the variable
and for the second method, it shows error
thank you.
@ainaasyhda
can you check the columns of the datatable using below syntax
datatable.columns gives you all the column which you have in the datatable
and check the column which you have passed in the variable is there are not
Outputdt=Inputdt.asEnumerable.where(Function(row) row(Variable).equals(“OD”)).CopytoDatatable.
cheers
mkankatala
(Mahesh Kankatala)
August 29, 2023, 7:30am
5
Hi @ainaasyhda
Check the below linq expression
Outputdt = Inputdt.asEnumerable.Select(Function(row) row(Variable).equals("OD")).CopytoDatatable.
Note - In the Variable pass the variable which stores the column name.
Hope it helps!!
ainaasyhda
(Ainaa Syuhada)
August 29, 2023, 7:35am
6
Hi can I know the variable type for “Outputdt”, is it data table?
Also it showing error;
Thanks
mkankatala
(Mahesh Kankatala)
August 29, 2023, 7:38am
7
I have made a small wrong
Use the below one
Inputdt.AsEnumerable.Where(Function(row) row(Variable).equals("OD")).CopyToDataTable
Hope you understand!! @ainaasyhda
@ainaasyhda
use
Outputdt = Inputdt.asEnumerable.where(Function(row) row(Variable).equals(“OD”)).CopytoDatatable
it will helps
ainaasyhda
(Ainaa Syuhada)
August 29, 2023, 7:53am
9
Yay its working thank you!!!
1 Like
ainaasyhda
(Ainaa Syuhada)
August 29, 2023, 7:53am
10
its working !! thank youuu
1 Like
system
(system)
Closed
September 1, 2023, 7:59am
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.