As mentioned here: Double.TryParse Method (System) | Microsoft Learn
Yous should use Double.TryParse because Convert.ToDouble gives error if input is pure string. I tried Convert.ToDouble(“one”) and I got same error like you. So if you are not sure what’s the value in your current row item, go for Double.TryParse
These are my column names 1)Total case,2) New cases(1 day*) 3)New cases(last 60 days). I am using a data table to extract the values of these column names
ok. Please use the method Double.TryParse as I mentioned in my previous post.
Because your row values are not always numbers. It can sometimes be a pure string like “No Data”. Convert.ToDouble throws exception when it doesn’t find numbers in its argument
So when I gave an actual number in StringVar1 like “1.2”, the boolean output SuccessOrNot is true and the double value is available in the variable “DoubleNumber”
Similarly when I gave StringVar1 like “one”, the boolean output SuccessOrNot is false and therefore we shouldn’t consider output DoubleNumber in this case.
If you use same kind of code, pass CurrentRow(“YourColumnName”) instead of StringVar1. As you have SuccessOrNot boolean variable, use if condition to check the conversion is successful or not. Based on that you can make use of the result and move on to the next row.
Hope this helps you. Let me know if you are still facing any challenges at any step
In the below screenshot column some places there are integer values and some places it is mentioned No Data. What value should we replace with 'No Data ’ while converting from string to integer.
Just use the same code as I gave in the invoke code screenshot(refer my previous reply). In the arguments , in the place of StringVar1 Value field give
CurrentRow(“New cases(1 day*”).tostring()
After that activity use an if condition. if(SuccessOrNot) then make use of the result DoubleNumber variable(this variable has your converted double value). There’s no need to write anything in else block
Use invoke code activity. Write the code I gave in previous screenshots. Click on edit arguments button in the invoke code activity and write same arguments as I gave in screesnhot except one value.
I’m again highlighting that value in the screenshot. In the position, instead of StringVar1, write
CurrentRow(“New cases(1 day*)”).tostring()
Use If Activity (condition SuccessOrNot = True), if SuccessOrNot value is true that means it converted successfully and use the DoubleNumber value further.
One more thing do I need to now directly enter the value StringVar1 = CurrentRow(“New cases(1 day*)”).tostring() in the invoked arguments value section and also in the variables section