NHoe
(Norman)
November 18, 2022, 2:14pm
1
Hello all,
thanks to the support in the forum I got a way to group values in a table, it works.
What is new is that the value to be grouped may not be in the table. How can I catch this problem?
That is, I would like to check if the value to be grouped is in the table at all before grouping it.
(From d In DT_from_Report.AsEnumerable
Group d By k=d(str_OrderNr).toString.Trim Into grp=Group
Select g=grp.CopyToDataTable).ToList
Gokul001
(Gokul Balaji)
November 18, 2022, 2:59pm
2
Hi @NHoe
You can try with this expression
(From d In DtBuild.AsEnumerable
Group d By k=d("Column name").toString.Trim Into grp = Group
Let ra = New Object(){k}
Select r = DtClone.Rows.Add(ra)).CopyToDataTable
Regards
Gokul
NHoe
(Norman)
November 21, 2022, 2:12pm
3
Hi @Gokul001
i get only one row, not all
(From d In DT_from_Report.AsEnumerable
Group d By k=d(“Number”).toString.Trim = OrderNr Into grp=Group
Let ra =New Object(){grp.First()(0),grp.First()(1),grp.First()(2),grp.First()(3),grp.First()(4)}
Select r=DT_clone.Rows.Add(ra)).CopyToDataTable
Gokul001
(Gokul Balaji)
November 21, 2022, 2:13pm
4
Hi @NHoe
Can you share the sample input and expected output
NHoe
(Norman)
November 21, 2022, 2:19pm
5
Hi @Gokul001
i want group the Number and after them i want all rows to this number
Kundennummer
Artikelnummer
LSNummer
LSposition
Anzahl
Number
523778
40-49-9844
702104086194
01
1
8107063
523778
40-46-8251
702104086194
02
1
8107063
523778
40-47-9314
702201615359
01
1
2861873
523778
40-28-4467
702201615359
02
1
2861873
523778
40-53-1906
702201686085
01
1
2861873
523778
40-45-4995
702203376824
03
1
3394732
523778
40-54-2993
702203376824
01
1
3394732
523778
40-28-4473
702203376824
02
1
3394732
Gokul001
(Gokul Balaji)
November 21, 2022, 2:22pm
6
Hi @NHoe
How about this expression
(From d In DtBuild.AsEnumerable
Group d By k=d("Number").toString.Trim Into grp = Group
Let ra = New Object(){grp.First()(0),grp.First()(1),grp.First()(2),grp.First()(3),grp.First()(4),k}
Select r = DtClone.Rows.Add(ra)).CopyToDataTable
Check out this Sample XAML file
GroupByLinq.xaml (18.7 KB)
Regards
Gokul
NHoe
(Norman)
November 21, 2022, 2:36pm
7
Gokul001:
New Object(){grp.First()(0),grp.First()(1),grp.First()(2),grp.First()(3),grp.First()(4),k}
Hi @Gokul001
it doesnt work, i get only the First row from the “Number”
for example = i start with the Group d By k=d(“Number”).toString.Trim = OrderNr Into grp=Group “8107063” and i want all rows from thet DataTable
Kundennummer
Artikelnummer
LSNummer
LSposition
Anzahl
Number
523778
40-49-9844
702104086194
01
1
8107063
523778
40-46-8251
702104086194
02
1
8107063
Gokul001
(Gokul Balaji)
November 21, 2022, 2:37pm
8
NHoe:
Kundennummer
Artikelnummer
LSNummer
LSposition
Anzahl
Number
523778
40-49-9844
702104086194
01
1
8107063
523778
40-46-8251
702104086194
02
1
8107063
523778
40-47-9314
702201615359
01
1
2861873
523778
40-28-4467
702201615359
02
1
2861873
523778
40-53-1906
702201686085
01
1
2861873
523778
40-45-4995
702203376824
03
1
3394732
523778
40-54-2993
702203376824
01
1
3394732
523778
40-28-4473
702203376824
02
1
3394732
Can you share the output for this? @NHoe
Gokul001
(Gokul Balaji)
November 21, 2022, 2:40pm
9
Have you tried with Filter data table activity @NHoe
ppr
(Peter Preuss)
November 21, 2022, 2:45pm
10
maybe you can elaborate more on this. GroupBy is working dynamic, so it will only use the present values.
NHoe
(Norman)
November 21, 2022, 2:48pm
11
That works fine, thank you!
1 Like
system
(system)
Closed
November 24, 2022, 2:49pm
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.