I need to get the total sum of the column of a DataTable. My Data Table has just a columm type String, such as " 20130 EUR". I want to obtain the total of this columm in format number without the “EUR”. Can I use some activity for this?.Thanks
The solution provided by @prashant1603765 , will definately works. just in case if you want to have a dynamic apporach i.e., not just EUR but anything apart from numbers, then you can use below logic
1. Create a variable of type string. Ex: Total
2. Select Assign activity
3. Total = YourDatatable.AsEnumerable().Sum(Function(row) CDbl(System.Text.RegularExpressions.Regex.Match(row.("YourColumnName").ToString(), "[\d.,]+").Value)).ToString()
With this you should get total of respective column
total is type Double. In “Assign” activity I use your expression:
total = yourDataTable.AsEnumerable().Sum(Function(row) CDbl(row(“YourColumnName”).ToString.Trim.Replace(" EUR", “”)))
I get Error ERROR Validation Error BC30512: Option Strict On disallows implicit conversions from ‘Boolean’ to ‘Double’. The selected value is incompatible with the property type
Might be quotes issue check by past at Notepad
Check this,
total = yourDataTable.AsEnumerable().Sum(Function(row) CDbl(row(“YourColumnName”).ToString.Trim().Replace(" EUR", “”)))