Quantcast
Channel: UiPath Community Forum - Topics tagged error
Viewing all articles
Browse latest Browse all 4384

Improve Linq query group by and sum

$
0
0

Hello,

I need help regarding my Linq query

I group by “Name” and sum the “Montant HT” but i need also to sum the “REGUL HT” (when there is a regul).

Which means that my client’s excel file, there are amounts in “Regul HT” and sometimes rows are empty.

The linq was perfectly working, but when i have added the “Let sr =…”
see below
(From d In dtData.AsEnumerable
Group d By k1= d.item(“Name”).ToString Into grp= Group
Let s = grp.Sum(Function (x) CDbl(x(“Montant HT”).toString.Trim))
Let sr = grp.Sum(Function (x) CDbl(x(“REGUL HT”).toString.Trim))
Let ra = New Object(){grp.First()(0),grp.First()(1),grp.First()(2),grp.First()(3),k1,s, grp.First()(6),sr,grp.First()(8)}
Select dt_Asset.Rows.Add(ra)).CopyToDataTable

I have a error message : Assign: Conversion from string “” to type ‘Double’ is not valid.
Because on my Excel file, in the column “Regul HT” Some rows are empty.

How can I do pay attention only if “Regul HT” is fill in, please ?

@MAHESH1
@AkshaySandhu
@GBK

5 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 4384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>