This is my input DT. I want to get the total value only for Done.
Flag | Value |
---|---|
Done | 23 |
Done | 43 |
Error | 54 |
Error | 65 |
Done | 75 |
Error | 76 |
Expected Output: 141
This is my input DT. I want to get the total value only for Done.
Flag | Value |
---|---|
Done | 23 |
Done | 43 |
Error | 54 |
Error | 65 |
Done | 75 |
Error | 76 |
Expected Output: 141
Hi @Random_Bot ,
You can do it as below:
(From row In your_dt.AsEnumerable() Where row("Flag").ToString() ="Done" Select Cdbl(row("Value"))).Sum()
I hope this works for you.
Regards,
Vinit Mhatre
Hi @Random_Bot
Try this linq expression:
totalValue = (From row In inputDt.AsEnumerable() Where row.Field(Of String)("Flag") = "Done" Select Convert.ToInt32(row.Field(Of Int32)("Value"))).Sum()
totalValue
is of DataType System.Int32.
Regards
Thanks @Vinit_Mhatre & @vrdabberu
Happy Automation !!
Regards,
Vinit Mhatre
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.