Hello All,
I have a challenge where if “invoice” & “Batch” are having the same data values, then “Amount” should be added
input :
output:
Thank you
Hello All,
I have a challenge where if “invoice” & “Batch” are having the same data values, then “Amount” should be added
input :
output:
Thank you
You can try this
dt = dt.AsEnumerable.GroupBy("function(x) x("invoice").ToString).Select(function(g) dt.LoadDataRow({g.key.ToString,g.Sum(function(y) y("Amount").ToString).ToString,g.First()("Batch").ToString},False)).CopyToDataTable
Cheers
I’m getting warning That “g” is not declared or inaccessible
So instead of g i should put x ?
Sorry I’m a little confused.
Hi @Yugal_Raju ,
please check this query
(
From row In dt_Input.AsEnumerable
Group row By a= row("Invoice").ToString.Trim,b=row("Batch").ToString.Trim Into grp=Group
Let s=grp.Sum(Function(x) CDbl(x("Amount").ToString.Trim))
Let ra= New Object(){a,s,b}
Select dt_Output.Rows.Add(ra)
).CopytoDataTable
GroupBy_2Columns_And_Sum.xaml (8.4 KB)
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.