Filter data table by column with different data types

excel
activities

#1

Hello,

I have a problem with filtering data table via column where I have values such as:

X
04/23/2018 00:00:00
FC Done,Please check

When I do it like
new_dt = old_dt.Select("[Column] = 'X'").CopyToDataTable it works perfectly.

Unfortunately when I try to filter X and FC Done,Please check like:
new_dt = old_dt.Select("[Column] in ('X','FC Done,Please check')").CopyToDataTable I get an error:
image
What is interesting when I try to filter “FC Done,Please check” with
new_dt = old_dt.Select("[Column] = 'FC Done,Please check'").CopyToDataTable I get the same error.
It seems something is wrong with data types or so.
Do you have any idea how I could deal with this problem?

Much thanks in advance.


#2

@Rafal_Bartko

Try this
new_dt = old_dt.Select(“Convert([Column],System.String) = ‘FC Done,Please check’”).CopyToDataTable

Sorry I forget to add Convert.

Regards,
Mahesh


#3

Unfortunately, it doesn’t work.
I get error that it cannot find column [Column,System.String]

Regards,
Rafal


#4

@Rafal_Bartko

You have to replaca the Column by your Column Name

Regards,
Mahesh


#5

Yeah I did that of course.
It still takes [My column name,System.String] as whole column name.

Regards,
Rafal


#6

@Rafal_Bartko

Can you just share the screen shot


#7

Yes, sure.
This is what I get:
image

The code I used in Assign activity:
dt_schedule.Select("[Formal Check,System.String] = 'FC Done,Please check'").CopyToDataTable

Regards,
Rafal


#9

Hey @Rafal_Bartko

Try this
dt_schedule.Select(“Convert([Formal Check],System.String) = ‘FC Done,Please check’").CopyToDatatable

Regards,!!
Aksh


#10

Hello!
I’ve tried and got such exception:
image

Regards,
Rafal


#11

Hey @Rafal_Bartko

Corrected -dt_schedule.Select(“Convert([Formal Check],System.String) = ‘FC Done,Please check’").CopyToDatatable

sample.xaml (6.8 KB)

Regards,!!
Aksh


#12

Hello @aksh1yadav

It works! Thank you very much.
So it has converted [Formal Check] column’s type into String and then selected, right?
Is this VB?

Regards,
Rafal


#13

Yes but you should use when your column type is different. so in my example case the column type is by default a string so even if i will omit convert and use only simple column name and string to compare it will work :slight_smile:

Regards,!!
Aksh