EDN Admin
Well-known member
<br/>
Good morning,<br/>
<br/>
Im trying to apply a simple way to solve a small problem, but I am not able to solve.<br/>
<br/>
I am using the following data table<br/>
<br/>
<br/>
row<span style="white-spacere Num<span style="white-spacere
Item<span style="white-spacere Count<span style="white-spacere
Item1<span style="white-spacere Item2<br/>
1<span style="white-spacere 2<span style="white-spacere A,B<span style="white-spacere
40<span style="white-spacere A<span style="white-spacere
B<br/>
2<span style="white-spacere 2<span style="white-spacere E,H<span style="white-spacere
30<span style="white-spacere E<span style="white-spacere
H<span style="white-spacere <br/>
3<span style="white-spacere 2<span style="white-spacere A,E<span style="white-spacere
20<span style="white-spacere A<span style="white-spacere
E<br/>
4<span style="white-spacere 2<span style="white-spacere F,G<span style="white-spacere
20<span style="white-spacere F<span style="white-spacere
G<br/>
5<span style="white-spacere 2<span style="white-spacere A,D<span style="white-spacere
10<span style="white-spacere A<span style="white-spacere
D<br/>
6<span style="white-spacere 2<span style="white-spacere A,C<span style="white-spacere
10<span style="white-spacere A<span style="white-spacere
C<br/>
7<span style="white-spacere 2<span style="white-spacere E,B<span style="white-spacere
10<span style="white-spacere E<span style="white-spacere
B<br/>
8<span style="white-spacere 2<span style="white-spacere B,D<span style="white-spacere
10<span style="white-spacere B<span style="white-spacere
D<br/>
9<span style="white-spacere 2<span style="white-spacere B,C<span style="white-spacere
10<span style="white-spacere B<span style="white-spacere
C<br/>
<br/>
<br/>
the goal is to store another table the row where the value with item appears more often.<br/>
<br/>
The problem is that I must be doing something wrong where I can not identify the line<br/>
<br/>
<br/>
Dictionary<string, Items> list_max = new Dictionary<string, Items>();<br/>
foreach (Items s in List_Initial)<br/>
{<br/>
string val_item = s.Item;<br/>
double max = 0;<br/>
<span style="white-spacere cont=2;<br/>
for (int a = 1; a < cont; a++)<br/>
{<br/>
<br/>
string expression = "item" + a +"=" +val_item +"";<br/>
DataRow[] foundRows;<br/>
<br/>
// Use the Select method to find all rows matching the filter.<br/>
foundRows = _tab_resul.Select(expression);<br/>
<br/>
DataTable temp = new DataTable();<br/>
temp = foundRows.CopyToDataTable();<br/>
var maxRow = temp.Select("item" + a +"= MAX(" + "item" + a +")");<br/>
<br/>
}<br/>
<span style="white-spacere }<br/>
<br/>
<br/>
Item B for example, appears on lines {1,7,7,8}, but what I save in another table is the the resukts in line 1.<br/>
<br/>
this process for all items<br/>
<br/>
Thanks
View the full article
Good morning,<br/>
<br/>
Im trying to apply a simple way to solve a small problem, but I am not able to solve.<br/>
<br/>
I am using the following data table<br/>
<br/>
<br/>
row<span style="white-spacere Num<span style="white-spacere
Item<span style="white-spacere Count<span style="white-spacere
Item1<span style="white-spacere Item2<br/>
1<span style="white-spacere 2<span style="white-spacere A,B<span style="white-spacere
40<span style="white-spacere A<span style="white-spacere
B<br/>
2<span style="white-spacere 2<span style="white-spacere E,H<span style="white-spacere
30<span style="white-spacere E<span style="white-spacere
H<span style="white-spacere <br/>
3<span style="white-spacere 2<span style="white-spacere A,E<span style="white-spacere
20<span style="white-spacere A<span style="white-spacere
E<br/>
4<span style="white-spacere 2<span style="white-spacere F,G<span style="white-spacere
20<span style="white-spacere F<span style="white-spacere
G<br/>
5<span style="white-spacere 2<span style="white-spacere A,D<span style="white-spacere
10<span style="white-spacere A<span style="white-spacere
D<br/>
6<span style="white-spacere 2<span style="white-spacere A,C<span style="white-spacere
10<span style="white-spacere A<span style="white-spacere
C<br/>
7<span style="white-spacere 2<span style="white-spacere E,B<span style="white-spacere
10<span style="white-spacere E<span style="white-spacere
B<br/>
8<span style="white-spacere 2<span style="white-spacere B,D<span style="white-spacere
10<span style="white-spacere B<span style="white-spacere
D<br/>
9<span style="white-spacere 2<span style="white-spacere B,C<span style="white-spacere
10<span style="white-spacere B<span style="white-spacere
C<br/>
<br/>
<br/>
the goal is to store another table the row where the value with item appears more often.<br/>
<br/>
The problem is that I must be doing something wrong where I can not identify the line<br/>
<br/>
<br/>
Dictionary<string, Items> list_max = new Dictionary<string, Items>();<br/>
foreach (Items s in List_Initial)<br/>
{<br/>
string val_item = s.Item;<br/>
double max = 0;<br/>
<span style="white-spacere cont=2;<br/>
for (int a = 1; a < cont; a++)<br/>
{<br/>
<br/>
string expression = "item" + a +"=" +val_item +"";<br/>
DataRow[] foundRows;<br/>
<br/>
// Use the Select method to find all rows matching the filter.<br/>
foundRows = _tab_resul.Select(expression);<br/>
<br/>
DataTable temp = new DataTable();<br/>
temp = foundRows.CopyToDataTable();<br/>
var maxRow = temp.Select("item" + a +"= MAX(" + "item" + a +")");<br/>
<br/>
}<br/>
<span style="white-spacere }<br/>
<br/>
<br/>
Item B for example, appears on lines {1,7,7,8}, but what I save in another table is the the resukts in line 1.<br/>
<br/>
this process for all items<br/>
<br/>
Thanks
View the full article