Filter DataTable keeps only the headers

Hi,
I am using a filter data table activity to keep rows that contain “TRUE” in a certain column.

For some reason, the output contains only the headers. I confirmed also with a message box “dt.rows.count” I got 0.
I also checked “PreserveFormat” in the read range:
image

Please advise.
Thank you!

Hey,
can you show what the input file/datatable looks like?

image
Thank you

Try to use boolean value in the filter:
image

thanks @pikorpa ,still getting 0

hmmm. It’s weird.
I tried recreate your Excel file. Take a look to this workflow. Filter activity works fine:
FilterDT.zip (9.7 KB)

thanks @pikorpa ,
when I changed the TRUE in excel to yes, it works… any idea why?

@hp321

Once you read the datatable…try to open the locals panel and check how the value is being read in the datatable variable…from there we can use appropriate filter,at times it can read as 1 and 0 also

To check: Run in Debug → Keep a break point after read-> Locals panel → Datatable Variable->Click on magnifier to open

cheers

Hi @hp321

When you are using read range workbook activity to read the excel and store in a datatable.

Check the Add headers option in properties, then it will take it as headers.
After that use the Filter datatable activity with the same condition.

Hope it helps!!

Hi @hp321

  1. Just remove the double quotes around the true and use the suggested name true while your giving you’ll get the output as you required
  2. Or you can also select Filter rows - Remove - “Column2” != true

use this inbuilt true value
image

Hi @hp321

Use below expression

DT.Asenumerable.Where(Function(x) x(“Collections”).Tostring.Equals(“True”)).CopyToDatatable

Hope it will helps you :slight_smile:
Cheers!!

1 Like

@hp321

Blockquote thanks @pikorpa ,
when I changed the TRUE in excel to yes, it works… any idea why?

Yes, you must uncheck ‘PreverseFormat’ in properties and it will be works fine with true or false values :slight_smile:
image

2 Likes

thanks @Anil_G

tried what you suggested. when I had “yes”-showed as expected.
when I looked at the Locals it looked like the “TRUE” was a Boolean.
when I had even one “TRUE” and filtered as string or Boolean-showed headers only

thanks @mkankatala
I had checked the headers
image

@hp321

Did you use true without inverted quotes?

if you can send the file here cna give the exact filter you need

else you can go with linq as well in assign

dt = dt.AsEnumerable.Where(function(x) x("ColumnName").ToString.ToUpper.Equals("TRUE")).CopyToDataTable

Also it would be good if you can show a screenshot

cheers

1 Like

thanks @vinitha_yachamaneni
Still getting in the Locals headers only…

Hi @pikorpa, @Anil_G, @vinitha_yachamaneni, @mkankatala, @Nawazish_Ahmad
Thankfully, the issue had been resolved with your help. The filter worked after I unchecking the PreserveFormat. The Linq worked as well.
Thank you all!

2 Likes

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