Query datatable by remove out the row which contain first letter is "A"

datatable

#1

I need to remove the row that word contain first letter is “A”. In example row number 5, 6, 20, 21 and 23 must be remove from datatable

Please advise.
Appreciated for your kindliness sir.

image


#2

Hi @ChatchaiSh,
Can you use Datatable.Select("[Package Cd] LIKE ‘A%’") .So you will get new datatable with only contains A. After that you can use for each row activity to remove one by one…

Thanks and regards,
P.Ajithkumar


#3

Hi @ChatchaiSh,

       I Have attached the flow for your Reference .

Test1.xlsx (7.1 KB)
test.xlsx (7.8 KB)
Main.xaml (11.0 KB)

Thanks and Regards,
P.Ajithkumar


#4

Hi @ChatchaiSh,
I can suggest you like , Instead of deleting, just try to filter the datatable as you need.

you can try this,
dtTest.Select("[Column Name] not like ‘A%’ ").CopyTodatatable
The above code wil give you all the records where [Column Name] not starting with alphabet A.

Hope this can help you!

Regards,
SP


#5

Maybe

DT.Select("[Column Name] NOT LIKE ‘A%’").ToArray.Copytodatatable

will be more simple for this case.
So you do not need to use [for each] activity.

regrads


#6

Thank you very much. But I try changed the column name to be “Package Cd” to apply with my table. The program will error below.

"Cannot perform ‘Like’ operation on System.Double and System.String.


#7

CopyTodatatable command not identify to use. What I do missing?


#8

Hi @ChatchaiSh
Make Sure That package Cd Format is Text.

Thanks and Regards
P.Ajithkumar


#9

Here are the code that apply from your suggestion sir.

Main.xaml (11.2 KB)
test.xlsx (8.6 KB)
Test1.xlsx (7.9 KB)


#10

Sure…

Thanks and Regards
P.Ajithkumar


#11

Error shown : Cannot file column ['A]
Main2.xaml (9.1 KB)
test.xlsx (8.6 KB)
Test1.xlsx (7.9 KB)


#12

It show error "Cannot find column name ['A].
test.xlsx (8.6 KB)
Test1.xlsx (7.9 KB)
Main2.xaml (9.2 KB)


#13

It still show the error below.

image


#14

You can type it manually. You can only find ‘CopyTo’ then type datatable. ASAT

Regards,
SP


#15

Hi @ChatchaiSh
I have attached the flow for your reference
Main.xaml (12.0 KB)
Thanks and regards,
P.Ajithkumar


#16

You can Convert The format of the column general into Text.

Thanks and Regards
P.Ajithkumar


#17

Try this

DT.Select("Convert([Package Cd],'System.String') NOT LIKE 'A%'").CopyToDataTable


#18

@ddrdushy1 It’s worked !!! Thank you so much.

@Ajithkumar_P @SantoshPothina @lainh

And great thanks everyone for your time spent sir.


#19

This is because you typed

‘A%’

.
The formula should be

'A%'

The apostrophe: ' should be half width .


#20

HI @ChatchaiSh,
It has custom activity instead doing more code , can do it in a single activity to delete the rows by conditions.

Sample File :
DeleteRowSelect.zip (1.5 KB)

Regards
Balamurugan