Hi everyone! I have a data table from 1-10, how can I remove odd numbers and show the newData table with even numbers only
Its Easy, As simple as below
if(num%2 == 0){
âNumber is evenâ
}else{
âNumber is oddâ
}
Please mark this as resolved if your requirement met.
Thanks,
Anil
Hi @Duong,
Welcome to our Community!.
Check this attached xaml,
FilterData.xaml (4.9 KB)
Also check this post for more details
@Duong
As an alternate give a try on:
yourDataTableVar.AsEnumerable.Where( function ( row ) CInt(row(âyourColumnNameâ).toString) Mod 2 = 0).CopyToDataTable
same as @sarathi125 he answered faster and i didnât noticed
Thank you! I have tried but there is error: ColumnName doesnât belong to Datatable eventhough I set it in Build Datatable. How could I fix it?
You should mention correct column name which you had in the Build DataTable activity.
In the assign you can assign the filtered to the DT1 itself, else you need to have one more Assign Activity with DT2 = DT1.Clone this will create the columns in DT2.
Currently no Columns defined or created in DT2. Thats the problem.
Thank you, column name error is fixed. There is other error conversion into int doesnât work in this case. The input is int. How can I modify it?
@Duong
please provide us details on error (e.g. message). maybe give also some sample values on what you are using for conversion
The error as follows:
Source: Assign
Message: Conversion from string ââ to type âIntegerâ is not valid.
Exception Type: System.InvalidCastException
RemoteException wrapping System.InvalidCastException: Conversion from string ââ to type âIntegerâ is not valid. â> RemoteException wrapping System.FormatException: Input string was not in a correct format.
The data table print out like this:
Numbers
2
4
5
7
10
1
3
6
9
8
@Duong
can you share your xaml?
I cannot unfortunately. New userâŚ
From an array of Int I built a data table and added rows.
Now I have to remove odd numbers from the data table and show data table with even numbers only. Later I have to sort the data table ASC later.
ok give me some little time, keep in mind you could do it also directly on the Array
@Duong
have a look on doing that on the array directly
Duong.xaml (6.4 KB)
feel free to play with it or to integrate in your workflow
It works!! Thank you very much!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.