String to double 1

I am using the below code
Dt_billnotlodged = (From row in out_dt_final1021.AsEnumeravke.Where(Function(x) x (“Remarks”).tostring.tolower.contains(“bill not lodged”))
Group row by a =row(“Trim”) into grp =group
Let xsum =grp.sum(Function (x) CDbl(x(“Final Reportable in INR”). tostring.trim))
Select Dt_biklboylodged.rows.add({a,xsum})). copytodatatable
When I am using this I am getting error as conversion from string “” to type double is not valid.

Can anyone help me how to resolve this

Hi @0bb4628e217fd43ac86ac9294

Try the below syntax:

Dt_billnotlodged = (From row In out_dt_final1021.AsEnumerable().Where(Function(x) x("Remarks").ToString().ToLower().Contains("bill not lodged"))
                   Group row By a = row("Trim") Into grp = Group
                   Let xsum = grp.Sum(Function(x) If(Double.TryParse(x("Final Reportable in INR").ToString().Trim(), 0.0), CDbl(x("Final Reportable in INR").ToString().Trim()), 0.0))
                   Select Dt_biklboylodged.Rows.Add({a, xsum})).CopyToDataTable()

Hope it helps!!

@Parvathy thank you i have used this but my Final Reportable in INR is coming as 0

Hi @0bb4628e217fd43ac86ac9294

Can you share the excel file if it doesn’t contain confidential data.

Regards

I want the bot to give the column values of “Trim” and “Final Reportable in INR” but when I using the code which you have given bot is giving Trim values as same as excel but Final Reportable in INR is becoming 0 in spite of value are there in excel

Can anyone please help me

Hi @0bb4628e217fd43ac86ac9294

=> Build Data Table:
image
Output-> Dt_biklboylodged

=> Read Range Workbook
image
Output-> out_dt_final1021

=> Use below syntax in Assign:

Dt_billnotlodged = (From row In out_dt_final1021.AsEnumerable().Where(Function(x) x("Remark").ToString().Contains("Bill not lodged"))
                   Group row By a = row("Trim") Into grp = Group
                   Let xsum = grp.Sum(Function(x) If(Double.TryParse(x("Final Reportable in INR").ToString().Trim(), 0.0), CDbl(x("Final Reportable in INR").ToString().Trim()), 0.0))
                   Select Dt_biklboylodged.Rows.Add({CInt(a), CInt(xsum)})).CopyToDataTable()

=> Write Range Workbook Dt_billnotlodged back to excel
image

Sequence16.xaml (9.8 KB)

Regards