Hello, I am using a read range to read a certain excel file which contains many rows and columns with headers. I have saved it to a dtMasterfile variable. I am trying to use a filter data table to keep all rows where column “Mandatory Selection” equals Agree. It only writes out the sheet name. Not sure what the issue is.
"Mandatory Selection" equals "Agree"
If this not works then
"Mandatory Selection" Contains "Agree"
or if the above not works it’s better to use Linq query in assign activity
filteredDataTable = dtInput.AsEnumerable().Where(Function(row) row.Field(Of String)("Mandatory Selection") = "Agree").CopyToDataTable()
Hi @mojo001
Might be it was not filtered properly,you are using the filter datatable right, instead of that use the below linq expression in assign activity,
→ Use read range workbook activity to read the excel and store in a datatable called dt_Input.
→ The use the below linq expression in assign activity.
- Assign -> Output_dt = Input_dt.asenumerable.where(Function(X) X("Mandatory Selection").toString.tolower.equals("agree")).Copytodatatable()
→ Then use the write range workbook activity to write the Output_dt to the other sheet in excel.
Hope it helps!!
Hi @mojo001
dtFiltered = dtMasterfile.AsEnumerable().Where(Function(row) row("Mandatory Selection").ToString().Equals("Agree")).CopyToDataTable()
Regards,
Hi @mojo001 ,
Example Workflow
Step 1: Read Range
- Drag and drop the
Read Rangeactivity. - Set the
SheetName,Range(leave blank to read the whole sheet), and the output DataTable variable (e.g.,dtMasterfile).
Step 2: Filter Data Table
- Drag and drop the
Filter Data Tableactivity. - Set the
Input DataTabletodtMasterfile. - Set the
Output DataTableto a new DataTable variable (e.g.,dtFiltered). - In the
Filter Rowstab, configure the condition to filter the rows where “Mandatory Selection” equals “Agree”:- Column:
"Mandatory Selection" - Operation:
= - Value:
"Agree"
- Column:
Step 3: Write Range
- Drag and drop the
Write Rangeactivity. - Set the
SheetName,DataTabletodtFiltered, and theStartingCell(e.g., “A1”). - Make sure to enable the
AddHeadersoption if you want to write the headers.
Regards
Sandy
Thank you, this works!
1 Like
It’s my pleasure… @mojo001
Happy Automation!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.