If the column B values are same (Opportunity Names are exactly same) then I need to add up the Total value in Column M. Is there any Linq query for such conditions ?
For example,
in Column B AIA HK 1Yr Commit FY25 is same. I need to add up the corresponding values in column M(350,000+12,500+1000000)
I need to check if Oppty column has same value with same start date then add up those corresponding values in MFST commit column MFST-Amount.xlsx (7.9 KB)
Basically I need to check in Oppty Column B has same values with same start date in Column F, then add up those corresponding values in column M and get a single amount
You can achieve this using a LINQ query. Here is an example of how you can write the query to check if the values in Column B are the same and then add up the corresponding values in Column M: var result = dataTable.AsEnumerable() .GroupBy(row => row.Field(“ColumnB”)) .Select(group => new { OpportunityName = group.Key, TotalValue = group.Sum(row => row.Field(“ColumnM”)) }); This query groups the rows by the values in Column B and then sums the values in Column M for each group ​1​.
Bot said:
You can achieve this using a LINQ query. Here is an example of how you can write the query to check if the values in Column B
var result = dataTable.AsEnumerable()
.GroupBy(row => row.Field(“ColumnB”))
.Select(group => new
{
OpportunityName = group.Key,
TotalValue = group.Sum(row => row.Field(“ColumnM”))
});
This query groups the rows by the values in Column B and then sums the values in Column M for each group