How to Sum and select column in IF condition

Please correct my query,
As selected line no 7 want to add rest the query is working fine
Please correct my code line no-7 Let summ=

(
From row In in_Dt_Bajaj_Stock
Join row2 In in_Dt_DumpBajaj
On row(“Security_Concionate”) Equals row2(“Concanate no”)
Group row2 By a = row(“Security_Concionate”) Into grp = Group
Let sum = grp.Sum(Function(x) CInt(x(“Premium”)))
Let summ=If(grp.Where(Function(d) d(“Product Id”).ToString.Equals(“4056”)),grp.Sum(Function(d) CInt(d(“Tbr Sum Insured”))).select(Function(d) d(“Tbr Sum Insured”)).FirstOrDefault())
Let Product_Id = If(grp.Where(Function(x) x(“Product Id”).ToString.Equals(“4056”)).Select(Function(x) x(“Product Id”)).FirstOrDefault(), grp.FirstOrDefault()(“Product Id”))
Select Dt_DumpMatchedBajajStock.Rows.Add(a, If(grp.count>1,grp.Where(Function(x) x(“Product Id”).ToString.Equals(“4056”)).Select(Function(x) x(“Quote no”)).FirstOrDefault(),grp.FirstOrDefault()(“Quote no”).ToString()),
sum, summ)).CopyToDataTable

Hello,

Try this correct version of line 7

Let summ = If(grp.Any(Function(d) d(“Product Id”).ToString.Equals(“4056”)),
grp.Where(Function(d) d(“Product Id”).ToString.Equals(“4056”)).Sum(Function(d) CInt(d(“Tbr Sum Insured”))),
0)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.