hp321
(ap)
December 21, 2023, 11:16pm
1
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:
Please advise.
Thank you!
pikorpa
(Piotr Kołakowski)
December 21, 2023, 11:19pm
2
Hey,
can you show what the input file/datatable looks like?
pikorpa
(Piotr Kołakowski)
December 21, 2023, 11:39pm
4
Try to use boolean value in the filter:
hp321
(ap)
December 22, 2023, 12:23am
5
thanks @pikorpa ,still getting 0
pikorpa
(Piotr Kołakowski)
December 22, 2023, 12:34am
6
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)
hp321
(ap)
December 22, 2023, 12:52am
7
thanks @pikorpa ,
when I changed the TRUE in excel to yes, it works… any idea why?
Anil_G
(Anil Gorthi)
December 22, 2023, 4:43am
8
@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
mkankatala
(Mahesh Kankatala)
December 22, 2023, 4:50am
9
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
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
Or you can also select Filter rows - Remove - “Column2” != true
use this inbuilt true value
Hi @hp321
Use below expression
DT.Asenumerable.Where(Function(x) x(“Collections”).Tostring.Equals(“True”)).CopyToDatatable
Hope it will helps you
Cheers!!
1 Like
pikorpa
(Piotr Kołakowski)
December 22, 2023, 8:26am
12
@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
2 Likes
hp321
(ap)
December 22, 2023, 11:32am
13
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
hp321
(ap)
December 22, 2023, 11:34am
14
thanks @mkankatala
I had checked the headers
Anil_G
(Anil Gorthi)
December 22, 2023, 11:40am
15
@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
hp321
(ap)
December 22, 2023, 12:08pm
16
thanks @vinitha_yachamaneni
Still getting in the Locals headers only…
hp321
(ap)
December 23, 2023, 6:41pm
17
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
system
(system)
Closed
December 26, 2023, 6:42pm
18
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.